Example of the NotifyNewData, NotifyInsertWorkSet, and NotifyDeleteRecordSet Notifications
The following code is an example usage of the NotifyNewData, NotifyInsertWorkSet, and NotifyDeleteRecordSet notifications:
// First let's check if there's any change to the client workset.
this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_NEW_DATA"), function
(){
// Yes indeed.
this.SetProperty ("primeRenderer", true);
});
// Now let's say our business is with the 4th record. We want to track if this record
is replaced.
// First we see if this 4th record is being deleted.
this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_DELETE_WORKSET"),
function (propSet){
if (propSet.GetProperty("index" === 3){// 3 because count starts at 0
if (propSet.GetProperty("nr") === 1 || propSet.GetProperty("NumRows") === 1){
if (this.Get("primeRenderer")){
this.Set("deleted", 4);
}
}
}
});
// Next to the insertion
this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_INSERT_WORKSET"),
function (propSet){
var underReplacement = this.GetProperty ("deleted");
if (this.Get("primeRenderer") && propSet.GetProperty("index") ===
this.GetProperty("deleted")){
// All conditions met. Now we'll get some info from what is being added.
var childPS = propSet.GetChildByType (consts.get("SWE_FIELD_VALUE_STR"));
var fieldArray;
CCFMiscUtil_StringToArray
(childPS.GetProperty(consts.get("SWE_PROP_VALUE_ARRAY")), fieldArray);
this.SetProperty ("New_Name_Value", fieldArray[2]);
this.SetProperty ("primeRenderer", false);
}
});