Two Buttons with ShowPopup on Same Applet

ShowPopup method is yet another old timer method that I have deployed more than a couple of times.

ShowPopup is self explanatory – the method is used on a button and it will enable you to popup a defined applet on top of the base applet. Of course, the base can itself be a popup applet – at times we are entitled for some fun at the users’ expense.

Defining a button with ShowPopup is easy.

  1. Create a button on applet with ‘Method Invoked’ as ShowPopup
  2. Define the following user properties for the control
    Popup = My Own Super Popup Applet
    Mode = Edit
    

All is fine up to this point. But, what if you have two popup buttons? That is simple enough – create two buttons and repeat the above story.

But, what if you want to write code to be triggered on click of the popup button?

Typically the named method is used to trigger off custom code before the actual method is invoked in case of other methods.

switch (MethodName) {
   case "ShowPopup":
         // do something
         iReturn = CancelOperation;
         break;
}
return (iReturn);

If there are two buttons with the same method called “ShowPopup”, we have a problem recognizing just when the logic needs to be triggered. As Siebel developers we are well aware of this complexity coming towards us from the darkest corners.

And, as Siebel developers, we know there are plenty of work around solutions.

Turns out, you can just invoke a custom method and use one of the myriad OOB services to trigger popup applets after the custom code.

To do this –

  1. Create a button on applet with ‘Method Invoked’ as “DoSomethingSuper”
  2. Write the following code in the PreInvokeMethod
    switch (MethodName) {
       case "DoSomethingSuper":
          // do something super
          HandlePopup ("Something Super Popup Applet");
          iReturn = CancelOperation;
          break;
    
       case "AndThenSome":
          // do some beyond amazing
          HandlePopup ("Amazing Popup Applet");
          iReturn = CancelOperation;
          break;
    }
    return (iReturn);
    
  3. Create a function called HandlePopup
    function HandlePopup(sApplet)
    {
       var bsSLM = TheApplication().GetService("SLM Save List Service");
       var psIn = TheApplication().NewPropertySet();
       var psOut = TheApplication().NewPropertySet();
       psIn.SetProperty("Applet Height", "400");
       psIn.SetProperty("Applet Mode", "2");                          
       psIn.SetProperty("Applet Name", sApplet);
       psIn.SetProperty("Applet Width", "800");
       bsSLM.InvokeMethod("LoadPopupApplet", psIn , psOut);
    }

That is it!

Now you have your own super and amazing logic that will trigger for a specific button click and will later invoke the popup.

But, do note that all is not well with this approach. If you try to popup another applet on top of the popup applet invoked through the above method, you will get the below error

View: <> does not contain applet: <?>. (SBL-UIF-00401).

There is no known work around other than simplifying the crazy things you are attempting to do.