How to use showpopup method for required fields

This is the first post for this blog. To start with I have picked a topic which is most ignored feature of Siebel. The showpopup method.

In one of the projects that I worked upon, we had a requirement to invoke a popup window on a button click. Nah! it wasnt that a simple requirement. I know requirements are never simple. But when we delivered this requirement as requested, the client was really happy(they always are...:-)...ain't they?). The details of the requirement are as descibed below.

Requirement: On a button click, call a particular interface to send a message to an external system but a few field values are required while sending the request to this external system.

Normally we write a script to getfield the values and then do a raise error text to show an alert. But this isnt a user friendly approach. Once the user sees the error, they need to navigate to the appropriate field; fill in the values and then click again and again untill all the values are provided.

Instead, we took a different approach. The design was to check if the field values are populated, if they are not then invoke a window with the popup applet having just fields that are required and ask the user to fill in the required field values. Once the user fills in the field values, go ahead with the interface call.

Detailed design.
1. Create a new control as MiniButton and place the control on the parent applet. The method invoked must be "ShowPopup".

2. Create the Control User Properties for the inputs to the ShowPopup method.
Name: Popup Value: (Popup Applet Name)
Name: Mode Value: (like Base, Edit etc...default is Base mode)


3. Create a new popup applet. I am not going into details of the popup applet. Its same as any other applet. Just keep in mind to have the class as "CSSSWEFramePopup" and the Height and Width as per your requirement. Also this popup applet must contain only those fields that are required for the interface call.

4. Now write a script to make the Interface Call button enabled i.e. CanInvoke to "True" in the parent applet.

WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)
{
if(MethodName == "ShowPopup")
{
CanInvoke = "TRUE";
return (CancelOperation);
}
return (ContinueOperation);
}

5. Now the meat of the design. Write a code in the preinvoke method of the parent applet to check if the required fields for Interface call are available or not.

function WebApplet_PreInvokeMethod (MethodName)
{
if(MethodName == "ShowPopup")
{
var lFieldVal = this.BusComp().GetFieldValue("Some Field");
if (lFieldVal != null && lFieldVal != "")
{
CallInterface();
return (CancelOperation);
}
}
return (ContinueOperation);
}

What happens in the above code is, it checks for the field value and if the value is populated then it calls the interface function and does a canceloperation. This will not invoke the popup applet as the operation is cancelled. Whereas if the field doesnt have a value then it will continue with the normal Siebel operation and show the popup window.

6. The last step is some configuration and few lines of script in the popup applet. Add a control in the Popup Applet with the name "Ok' and method "CloseApplet". This button is to close the applet.

Finally add the following code in the invoke method of the popup applet.

function WebApplet_InvokeMethod (MethodName)
{
if(MethodName == "CloseApplet")
{
var lFieldVal = this.BusComp().GetFieldValue("Some Field");
if (lFieldVal != null && lFieldVal != "")
{
CallInterface();
}
else
{
TheApplication().RaiseError("This field is required");
}
}
}

Note: In this requirement the popup applet and parent applet are based on the same BC. You can experiment with other BC's as well like if we have the child BC fields required.

Compile both the applets and Voila you would have Zapped your Siebel!!!

No comments:

Post a Comment