Configuring Siebel Open UI > Example of Customizing Siebel Open UI > Process of Customizing the Presentation Model >

Customizing the Presentation Model to Delete Records


This task is a step in Process of Customizing the Presentation Model.

Figure 22 illustrates the code you use to configure the presentation model to delete records. In this topic, you configure Siebel Open UI to customize and conditionally override the InvokeMethod method. Each number in this figure identifies the corresponding step number in the numbered task list that this book includes immediately after this figure.

Figure 22. Customizing the Presentation Model to Delete Records

To customize the presentation model to delete records

  1. In the recyclebinpmodel.js file, add the method that Siebel Open UI uses to delete a record:

    this.AddMethod("InvokeMethod", PreInvokeMethod, {sequence:true, scope:this});

    You must identify the method that Siebel Open UI uses when the user clicks Delete. To do this identification, it is recommended that you examine the flowchart that Siebel Open UI uses during a typical life cycle when it calls methods that reside on the Siebel Server. For this example, the life cycle flowchart indicates that Siebel Open UI calls the DeleteRecord method when it calls the InvokeMethod method. You add this code in the Init method. For more information, see Life Cycle Flows That Create New Records in List Applets and DeleteRecord Method.

    This configuration is similar to the configuration you added in Step 1 that includes the AddMethod method and the sequence statement.

  2. Call the custom logic only if Siebel Open UI calls the DeleteRecord method:

    if ((methodName === "DeleteRecord") && !this.Get("InDeletion")){

    This code examines the value of the InDeletion property that you set up in Step 3.

  3. Set the InDeletion property to true only if Siebel Open UI starts the deletion process:

    this.SetProperty("InDeletion", true);

    This code determines whether or not Siebel Open UI is already running an instance of your custom delete process, and then makes sure that no more than one of these instances runs at the same time. The InDeletion property determines whether or not the deletion process is currently running.

    You could use the following code in the Init method to add this property:

    this.AddProperty("inDeletion", false)

    This example demonstrates how you can use SetProperty to use a property temporarily so that it is similar to a conditional flag. This example uses SetProperty to create this property only when necessary. If Siebel Open UI calls the Get method before it calls the SetProperty method, then the JavaScript returns a value of undefined, which is the default value that JavaScript assigns to any variable that is not defined.

  4. Get the set of records where the Selected value of each of these records includes a check mark:

    var deletionPending = this.Get("DeletionPendingSet");

    This code gets the state of the set of records before the user clicks Delete. Siebel Open UI stores this information in the DeletionPendingSet property in the LeaveField customization that you added in Step 6.

  5. Determine whether or not the user has chosen at least one record for deletion:

    if (deletionPending.length > 0){

    This code represents this condition as > 0, where 0 indicates the number of records chosen.

  6. Iterate through all the records that the user has chosen to delete:

    for (var counter = deletionPending.length - 1; counter >= 0; counter--){
      var currentObj = deletionPending[counter];
      if (currentObj){
      }
    }

  7. Disable the processing that Siebel Open UI does for the control that is in focus:

    this.ExecuteMethod("SetActiveControl", null);

    For more information, see Disabling Automatic Updates and SetActiveControl Method.

  8. Modify the application state so that Siebel Open UI references the record that it must delete:

    this.ExecuteMethod ("HandleRowSelect", counter, false, false);

    To identify this code when you customize Siebel Open UI, it is recommended that you examine Flow That Handles Navigation to Another Row in List Applets. In this example, this flow indicates that you must use the HandleRowSelect method. The presentation model that Siebel Open UI uses for list applets references HandleRowSelect, so you can configure Siebel Open UI to use ExecuteMethod to call it. For more information, see HandleRowSelect Method.

  9. Make sure that Siebel Open UI can call the DeleteRecord method:

    if(this.ExecuteMethod("CanInvokeMethod", "DeleteRecord")){

    It is recommended that you configure Siebel Open UI to call CanInvoke before it calls another method to make sure that it can call this other method in the context of the object that is currently in scope. Siebel Open UI can use the CanInvoke method to model complex logic for any record that exists in the Siebel Database that resides on the Siebel Server. This logic can determine whether or not Siebel Open UI can call an operation according to the scope that it applies to the current object, such as a record that is in scope. In this example, it determines whether or not it can call the DeleteRecord method.

    You can use the method descriptions in Siebel Open UI Application Programming Interface to identify the method that you must use in your customization work.

    For more information about the method that this example uses, see CanInvokeMethod Method for Presentation Models.

  10. Add a property that Siebel Open UI can use to store information about the records that it sends to the Siebel Server for deletion:

    this.AddProperty("ObjectsUnderDeletion", []);

    Delete confirmation occurs through an asynchronous notification, so Siebel Open UI must back up the information that describes the record that it is about to delete. The notification handler requires this information so that it can do the post-processing work for this record. Subsequent steps in this topic describe this notification handler. For more information, see About Synchronous and Asynchronous Requests and Notifications That Siebel Open UI Supports.

  11. Delete the record:

    this.Get("ObjectsUnderDeletion")[this.Get("GetSelection")] = currentObj;
    var inputPS = SiebelApp.S_App.NewPropertySet();
    this.ExecuteMethod ("InvokeMethod", "DeleteRecord", inputPS);

    where:

    • ObjectsUnderDeletion inserts the record into a backed up record set, and if this insert occurs at an index location that is equal to the index of the selected row, then Siebel Open UI can reference the selected row to identify the correct index to use when processing the NotifyDeleteNotification reply. The Siebel Server sends this reply. Siebel Open UI must identify the record where it set the notification when it handles the NotifyDeleteNotifications notification. You can configure Siebel Open UI to call HandleRowSelect to select the row before it sends the request to delete the record.
    • GetSelection is a property of the applet presentation model that includes an index that identifies the chosen record. This record resides in the record set that resides in the client. When you develop your own customization, you can reference the documentation to identify the property that your customization requires. For more information, see Properties of the Presentation Model That Siebel Open UI Uses for Applets.
    • InvokeMethod is a method that resides in the presentation model that Siebel Open UI uses for a list applet. You can use ExecuteMethod to call it.
    • false configures Siebel Open UI to make a synchronous request to the Siebel Server. A synchronous request makes sure that Siebel Open UI sends all DeleteRecord requests to the server before it exits the loop. If it exits the loop during a synchronous request, then it sends all DeleteRecord requests sequentially. In this situation, it sends the requests to the server so that the server can process a reply for the previous request, including the delete completion notifications. The server does this processing during a synchronous request before it sends the next DeleteRecord request. You can also use an asynchronous request where Siebel Open UI sends all the DeleteRecord requests to the server before it processes any of the replies for these requests. For more information, see About Synchronous and Asynchronous Requests.
  12. Set the DeletionPendingSet property to zero:

    this.SetProperty("DeletionPendingSet", []);

    This code sets the DeletionPendingSet property to zero after Siebel Open UI finishes running all the DeleteRecord calls on the Siebel Server.

  13. Set the CancelOperation member of the returnStructure to true:

    returnStructure ["CancelOperation"] = true;

    You configure Siebel Open UI to set this member before it exits the outer loop that processes the deletionPending records. You do this so that Siebel Open UI does not use the DeleteRecord argument to make another call to the predefined InvokeMethod method. For more information about ReturnStructure, see AddMethod Method.

  14. Set the InDeletion flag to false:

    this.SetProperty("InDeletion", false);

    You configure Siebel Open UI to set this property before it exits the conditional block that does the InvokeMethod processing for the DeleteRecord method.

  15. Save the recyclebinpmodel.js file.

About Synchronous and Asynchronous Requests

Note the following:

  • A synchronous request is a type of request that Siebel Open UI sends to the Siebel Server, and then waits for a reply to this request before it continues any other processing.
  • An asynchronous request is a type of request that Siebel Open UI sends to the Siebel Server, and then continues other processing while it waits for a reply to this request.

The GetSelection request is synchronous, so Siebel Open UI cannot send another request to move the selection to a different record before the Siebel Server sends a reply notification that indicates a successful deletion. When processing this notification, the intended row is the same row that Siebel Open UI most recently selected. Siebel Open UI can use the selected row as a common index that it can use to reference the record. For information about how you can configure an asynchronous request, see Allowing Users to Interact with Clients During Business Service Calls.

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