Quantcast
Channel: siebel open ui – Siebel Unleashed
Viewing all articles
Browse latest Browse all 32

How to invoke business service in Siebel Open UI?

$
0
0

Well, when all the dust settles and novelty wears off we all have to get back to work and write code to accomplish business requirement. Open UI only changes the way you would write scripts but you still have to do it. So, without wasting much time here is the how you would invoke a Siebel Business Service on click of a button from Open UI.

Requirement:

You have button on an Applet that invokes a method name “Submit”. Invoke a business service to run validation on the current record.

Solution:

I am not including required PR and PM code to make it work. Just the working code required to call business service.The first step is to add the Invoke method handler in PM

InvokeMethod in PM

//When invoke method happens call Validate function
//sequence: true – invoke the Open UI code first
this.AddMethod( "InvokeMethod", Validate, { sequence : true, scope : this } );

Function Validate

function Validate(methodName, psInputArgs, lp, returnStructure){
//usual if or switch to handle different methods
if(methodName == "Submit"){
//define a new propertyset and set appropriate input arguments
var inPS = SiebelApp.S_App.NewPropertySet();
var service = SiebelApp.S_App.GetService( "Validate Data" ); //get service
if( service ){
var outPS = service.InvokeMethod( "Validate", inPS); //invoke the method
//on success we get a property set with type result set
var resultSet = outPS.GetChildByType("ResultSet");
if(resultSet){
//let assume we get a string as output
var errmsg = resultSet.GetProperty("errormsg");
if(errmsg != "")
this.SetProperty("requiredFields",errmsg); //this will be attached in PR to trigger UI behvior
}
}
SiebelApp.S_App.uiStatus.Free(); //to remove the wait icon
returnStructure ["CancelOperation"] = true;  //return cancel operation so nothing on Server side is invoked
}
}//end of function ValidateSR

In Siebel PR

this.GetPM().AttachPMBinding("requiredFields",showError,{scope:this});

Show error function will define what you would like to do on UI for example highlight the labels or show a dialog box.

Business Service Registration:

The last step is to register this and Client business service in Application User Property.

Name: ClientBusinessService10 (Number would vary based on your application)

Value: Validate Data

This is the step that necessitates creation a proxy business service so that you don’t have to do this for every business service that you are trying to invoke. Discussion of  Proxy Business Service is out of scope of this post and needs a post on its own. So, let’s leave that for a later time.

Do, let me know what else would you like me to post about.


Viewing all articles
Browse latest Browse all 32

Trending Articles