Runtime Events and Custom Business Services
By @lex on Oct 14, 2008
This is for all of you who work with Runtime Events and Action Sets in Siebel CRM.
Action Sets allow you to define one or more actions to be executed when the associated event occurs. There are three action types:
- Attribute Set: Set a profile attribute
- InvokeMethod: Invoke a method on the event object
- BusService: Call a business service method
However when it comes to calling your custom written business service method, then you find a note that you have to use the "Context" property to pass the arguments.
What happens when the action is executed is that the Siebel framework creates a property set which contains information about the runtime event and the content of the context field as a string.
We can use the EAI XML Write to File business service and its WritePropSet method to send the input property set to a file. This is what the file looks like when your business service is called from an action set:
- Object Name: The name of the object experiencing the event
- Business Component Name: The current active BC
- Context: The content of the Business Service Context field
- Action Set: The name of the action set
- Event Type: The type of event (BusComp, Applet or Application)
- EventId: The ROW_ID of the event
- Sub Event: The content of the Sub Event field (usually a method or field name)
- Action: The name of the action
- Event Name: The name of the event such as PreWriteRecord, etc....
"Param1", "Value1", "Param2", "Value2"
This is how it is used for standard business services like Workflow Process Manager. Note that the syntax contains strings in double quotes and they are separated by a comma and a space. Of course, for your custom written business service, you could use any other syntax but this may not be "close to the standard" and could cause problems in larger projects where other developers would not be aware of a different context string syntax.
So basically you have to split the string into the distinct values. Here is a code snippet which gives you the general idea:
//read the string from the input property set
var context_string = Inputs.GetProperty("Context");
//the split method creates a char array, we use comma and space as the delimiter
var context_array = context_string.split(", ");
//now we can get the parameters and values, the odd indexes contain the values
//use for() loops for larger arrays...
var param1 = context_array;
var param2 = contaxt_array;
//the replace() function uses regular expressions which are a little tricky
//see examples here
param1 = param1.replace(/\"/g,'');
param2 = param2.replace(/\"/g,'');
happy scripting ;-)