8/26/2010

Enable custom button on Applet


                Hello!

                Before I was gone to vacation, I had a requirement for which I needed to enable custom button on Applet with out using a script. As you may or my not know usual way to enable button on Applet is by using Applets Server Script like this (before scripting we create mini button Control with property “Method Invoked” set to name of you custom method in script, the we put this Control on Applet using “Edit Web Layout” option):

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)
{
                try
                {
                                var iReturn = ContinueOperation;
                                if (MethodName == "SomeMethodBehindButton")
                                {
                                                CanInvoke = "TRUE";     
                                                iReturn=CancelOperation;
                                }             
                }

                catch (e)
                {
                                iReturn=CancelOperation;
                                TheApplication().RaiseErrorText(e.errText);       
                }
                                                               
                return (iReturn);
}
 
                And:

function WebApplet_PreInvokeMethod (MethodName)
{
                try
                {
                                var iReturn = ContinueOperation;
                               
                                if (MethodName == "SomeMethodBehindButton")
                                {
                                                iReturn = RulesExplode();
                                }
                }

catch (e)
                {
                                iReturn=CancelOperation;
                                TheApplication().RaiseErrorText(e.errText);       
                }             
               
                return (iReturn);
}

                And:

function SomeMethodBehindButton()
{
                try
                {
                                var iRet = CancelOperation;
                               
                                //your cutom script
                }
                               
                catch (e)
                {
                                iRet = CancelOperation;
                                TheApplication().RaiseErrorText(e.errText);       
                }             
               
                finally
                {
                                //your custom finalization
                }
               
                return (iRet);                    
}

                So, why did I have this problem? Easy, by clicking this custom button I had to run Browser Script, but as you my know or not know (I will tell this some other time) the flow for running scripts is like this: Applets Browser Script – Applets Server Script – Business Components Browser Script – Business Components Server Script. This means that I can’t run Applets Server Script before Applets Browser Script and that I can’t enable button by using Applets Server Script if I want to use Applets Browser Script. So I searched the World Wide Web and in Siebel Unleashed blog found a way to do this.

                It is pretty simple – all that need to be done is just add two words in Controls “Method Invoke” property before your custom method name like this – “EventMethodSomeMethodBehindButton”. That’s all. Now we can use it like normal method using just “function WebApplet_PreInvokeMethod (MethodName)” and “function SomeMethodBehindButton()” or as in my case I use it in Browser Script.

                There is another way by using user properties, but I never used yet so need to check it before I can tell you more.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hie..
    Thanks for your post..
    I am also a Newbee in Siebel..
    My aim is to create a button in siebel applet and after clicking that button it should show an alert message... I tryed in the way you maintained but it is giving error as

    " The specialized method MyTEST is not supported on Business Component "Mktg Imports Jobs' used by Business Object 'Mktg Imports' .(SBL-DAT-003322) "

    Please give me some solution on it..

    ReplyDelete