So what does the committed Siebel developer do when it comes to create a button on a Siebel applet?
Of course, you'd start with adding a MiniButton control to the applet layout and specify the method to be invoked in the MethodInvoked property.
Such a button is visible on the applet but not clickable. The reason is that the Siebel framework does not "know" the custom method and the Siebel CanInvokeMethod event handler only enables "known" methods.
Most developers head for the applet script editor and add a server script similar to the following in the PreCanInvokeMethod event handler to enable the button.
The result is that the button is active and clickable, so we can now focus on implementing the desired functionality such as invoking a business service.
BUT: Very often, the script is repeated across dozens or hundreds of applets without any further logic, for example switching the button state depending on user or data attributes. The script just has to "be there" in order to make 'em damn buttons active. So we end up with a lot of script.
Or is there...?
Yes, there are various alternatives which I will discuss in this post.
Named Method User Property
If you wish to have a button which is always active and invokes a method or business service (or Siebel workflow process via the Workflow Process Manager business service), you simply declare the Named Method user property.
Even if you could do it on the applet, why not just do it on the business component? Usually the method should be enabled on all applets on a given BC, shouldn't it?
The syntax for business component side Named Method entries is as follows:
Name: Named Method N (where N is a sequential number)
Value: "MethodName", "INVOKE Command", "INVOKE Arguments"
Here is an example:
There are numerous examples in the Siebel Repository, so we can most probably copy an existing Named Method user prop and modify the sequence number and the value.
More information about the Named Method business component user property and the various "INVOKE" commands can be found in the Siebel Developer's Reference.
Once the Named Method user property is set at either the applet or BC level, the buttons (or Command objects) referencing the method are in an active state. There is NO SCRIPT NEEDED. This technique works at least since Siebel 2000.
CanInvokeMethod Applet User Property
In Siebel 8.0, a new applet user property named CanInvokeMethod has been introduced which is documented here. The benefit of this user property is that its value can be an expression (in Siebel Query Language) which returns TRUE or FALSE. So simple decision logic when to enable or disable a method can be implemented without scripting.
FrameEventMethod prefix
Originating in the "Synthetic Event Button" feature in interactive workflow processes in Siebel 7.7, the quite exotic "FrameEventMethod prefix" allows us to create a button which invokes a method and have it always enabled without the need for script or even user properties.
Using the string "FrameEventMethod" as a prefix for the name of the method to be invoked ensures that the Siebel event framework accepts the method, so it can be easily used in a workflow process event or similar. Don't believe it? Try it!
Summary
The truth about (script in) the PreCanInvokeMethod event handler?
It is rarely ever needed. There are various declarative alternatives which we can use in our everlasting effort to reduce the use of scripting while customizing Siebel CRM.
have a nice day
Wednesday, May 5, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment