Configuring Siebel Open UI > Reference Information for Siebel Open UI > Notifications That Siebel Open UI Supports >

Example Usage of Notifications


This topic describes example usage of notifications.

Example of the NotifyBeginNotifys Notification

The following code is an example usage of the NotifyBeginNotifys notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_DELETE_RECORD"), function (propSet){
  // Change has occurred at server BC. Do something here:
this.SetProperty ("Refresh_Renderer", true);
});

Example of the NotifyNewSelection Notification

The following code is an example usage of the NotifyNewSelection notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_NOTI_SELECTED"), function (propSet){
  if (propSet.GetProperty(consts.get("SWE_PROP_NOTI_SELECTED")) === "false")
    this.SetProperty ("rowBeingUnselected", propSet.GetProperty("SWE_PROP_BC_NOTI_ACTIVE_ROW"));
  }
});

Example of the NotifyNewFieldData Notification

The following code is an example usage of the NotifyNewFieldData notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_NEW_DATA_WS"), function (propSet){
  var field = propset.GetProperty(consts.get("SWE_PROP_NOTI_FIELD"));
  if (field === "Customer Last Name"){
    // Notify my extension that shows this value in a different way.
    this.SetProperty ("RefreshExtn", true);
  }
}

Example of the NotifyNewDataWorkset Notification

The following code is an example usage of the NotifyNewDataWorkset notification:

// Trap an incoming change to the field value to do some flagging.
this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_NEW_DATA_WS"), function (propSet){
  var field = propset.GetProperty(consts.get("SWE_PROP_NOTI_FIELD"));
  if (field === "Discount Percentage"){
    var childPS = propSet.GetChildByType (consts.get("SWE_PROP_FIELD_VALUES"));
    var value;
    CCFMiscUtil_StringToArray (fieldSet.GetProperty(consts.get("SWE_PROP_VALUE_ARRAY")), value);
    if (parseFloat(value) > 20){
      // Greater than 20% discount? Something fishy!
      this.SetProperty ("flagCustomer", true);
    }
  }
});

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);
  }
});

Example of the NotifyBeginQuery, NotifyNewFieldQuerySpec, and NotifyEndQuery Notification

The following code is an example usage of the NotifyBeginQuery, NotifyNewFieldQuerySpec, and NotifyEndQuery notifications:

// Let's see a simple example involving all the three. First we will take up the query start.
this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_BEGIN_QUERY"), function (){
  // Query begins - The renderer will use this notification to show a bubble box having a number of choices. This might be driven off of a dropdown in the actual applet - we already have the choices.
  this.SetProperty ("showBubble", true);
});
// Now we'll attach to Field Spec. If that dropdown has a pre default value, then we can highlight that choice in our bubble.
  this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_NEW_FIELD_QUERYSPEC"), function (propSet){
    if (propSet.GetProperty(consts.get("SWE_PROP_NOTI_FIELD") === "Customer Type"){
      var value = propSet.GetProperty(consts.get("SWE_PROP_VALUE");
      var bubbleValues = this.Get (bubbleValueArray);
      this.SetProperty ("SetBubbleHighlightIndex", bubbleValues.indexOf(value));
    }
});
// Next the obvious. The death of the bubble.
this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_END_QUERY"), function (){
  this.SetProperty ("showBubble", false);
});

Example of the NotifyEndNotifys Notification

The following code is an example usage of the NotifyEndNotifys notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_END"), function (){
  // No more notifications. Mark for UI Refresh.
  this.SetProperty ("refreshUI", true);
});

Example of the SWEIRowSelection Notification

The following code is an example usage of the SWEIRowSelection notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_GENERIC"), function (propSet){
  var type = propSet.GetProperty(consts.get("SWE_PROP_NOTI_TYPE"));
  if (type === "SWEIRowSelection"){
    var argsArray;
    CCFMiscUtil_StringToArray (propSet.GetProperty(consts.get("SWE_PROP_ARGS_ARRAY"), argsArray);
    if (argsArray[6] === "1"){
      this.SetProperty ("SixthRowSelected", true);
    }
  }
});

Example of the BegRow Notification

The following code is an example usage of the BegRow notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_GENERIC"), function (propSet){|
  var type = propSet.GetProperty(consts.get("SWE_PROP_NOTI_TYPE"));
  if (type === "BegRow"){
    var argsArray;
    CCFMiscUtil_StringToArray (propSet.GetProperty(consts.get("SWE_PROP_ARGS_ARRAY"), argsArray);
    this.SetProperty ("beginRow", parseInt(argsArray[1]));
  }
});

Example of the GetQuickPickInfo Notification

The following code is an example usage of the GetQuickPickInfo notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_GENERIC"), function (propSet){
  var type = propSet.GetProperty(consts.get("SWE_PROP_NOTI_TYPE"));
  if (type === "GetQuickPickInfo"){
    var argsArray;
    CCFMiscUtil_StringToArray (propSet.GetProperty(consts.get("SWE_PROP_ARGS_ARRAY"), argsArray);
    if (argsArray[5] === "MyValue"){
      // Ah so the dropdown contains a value that we dont like..
      // Let us be evil and disable it!
      this.SetProperty ("disablePick", true);
    }
  }
});

Example of the ClosePopup Notification

The following code is an example usage of the ClosePopup notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_GENERIC"), function (propSet){
  var type = propSet.GetProperty(consts.get("SWE_PROP_NOTI_TYPE"));
  if (type === "ClosePopup"){
    // The below is just an example. PM's should not alert anything. Leave that to the PRs.
alert ("Make sure you have collected all details. You next operation will save the record!");
  }
});

Example of the SWEAInvokeMethod Notification

The following code is an example usage of the SWEAInvokeMethod notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_GENERIC"), function (propSet){
  var type = propSet.GetProperty(consts.get("SWE_PROP_NOTI_TYPE"));
  if (type === "SWEAInvokeMethod"){
    if (argsArray[1] === "NewRecord"){
    // Ah so there's going to be a new record that has happened as a chain.
    // Let's set a property so that we can do an AddMethod on this NewRecord,
    // and extend it to our liking
      this.SetProperty ("isChained", true);
    }
  }
});

Example of the NotifyStateChanged Notification

The following code is an example usage of the NotifyStateChanged notification:

this.AttachNotificationHandler(consts.get("SWE_PROP_BC_NOTI_STATE_CHANGED"), function (propSet){
  var type = propSet.GetProperty("type");
  var value = propSet.GetProperty("value");
  // This is just an example. Switch-case is preferred if multiple types need to
  // have custom logic
  if (type === "cr" || type === "CurRowNum"){
    // Current Row has changed at the server.
    if (value === this.Get("MyPreviouslyStoredActiveRow")){
      // Or not! What's going on. Something wrong with my logic?
      }
  }
  if (type === "nr" || type === "NumRows"){
    if (parseInt(value) > 1000){
      // Woah, this user seems to be going through a lot of records!
      // Shouldn't she be using the query function?
      this.SetProperty ("AlertUser", true);
    }
  }
  ...
  ...
});

Configuring Siebel Open UI Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.