Calling Methods

The example in this topic describes how to call a method when the user clicks a button.

To call methods for buttons

  1. Modify the plug-in wrapper:

    1. Use a JavaScript editor to open the plug-in wrapper for the button.

    2. Locate the click handler for the button.

    3. Add the following code to the code you located in Step b:

      var inPropSet = CCFMiscUtil_CreatePropSet();
      //Define the inPropSet property set with the information that InvokeMethod sends 
      as input to the method that it calls.
      var ai= {};
      ai.async = true;
      ai.selfbusy = true;
      ai.scope = this;
      ai.mask = true;
      ai.opdecode = true;
      ai.errcb = function(){
        //Code occurs here for the method that Siebel Open UI runs if the AJAX call fails
        };
      ai.cb = function(){
        //Code occurs here for the method that Siebel Open UI runs if the AJAX call is 
      successful
        };
      this.GetPM().ExecuteMethod("InvokeMethod",input arguments, ai);
      

      where:

      • input arguments lists the arguments that InvokeMethod sends as input to the method that it calls.

        For example, the following code specifies to use the InvokeMethod method to call the NewRecord method, using the properties that the inPropSet variable specifies for the ai argument:

        this.GetPM().ExecuteMethod("InvokeMethod", "NewRecord", inPropSet, ai)
        

        For more information, see InvokeMethod Method for Application Models and NewRecord Method.

  2. Modify the presentation model:

    1. Use a JavaScript editor to open the presentation model for the applet that you must modify.

    2. Locate the code that calls the Init method.

    3. Add the following code to the code that you located in Step b:

      this.AttachPreProxyExecuteBinding("method_name", function(methodName, inputPS, 
      outputPS){// Include code here that Siebel Open UI runs before the applet proxy 
      sends a reply.});
      
      this.AttachPostProxyExecuteBinding("method_name", function(methodName, inputPS, 
      outputPS){// Include code here that Siebel Open UI runs after the applet proxy 
      sends a reply.});
      

      where:

      • method_name identifies the name of the method that InvokeMethod calls. Note that Siebel Open UI comes predefined to set the value of the methodName argument in the following code to WriteRecord, by default. You must not modify this argument:

        function(methodName, inputPS, outputPS)
        

        For example:

        this.AttachPreProxyExecuteBinding("WriteRecord", function(methodName, inputPS, 
        outputPS){// Include code here that Siebel Open UI runs before the applet proxy 
        sends a reply.});
        
        this.AttachPostProxyExecuteBinding("WriteRecord", function(methodName, inputPS, 
        outputPS){// Include code here that Siebel Open UI runs after the applet proxy 
        sends a reply.});
        

        For more information, see WriteRecord Method, AttachPostProxyExecuteBinding Method, and AttachPreProxyExecuteBinding Method.