Google
 
We have moved to a http://siebelunleased.com Please visit there for updated posts

Sunday, October 7, 2007

Siebel How To - enable or disable a button conditionally?

I was working on my desk one day and newbie to siebel approached me to ask a question(also a avid reader on asked me the same question on mail). He asked me about a simple requirement or rather I should say the requirement that appeared simple to me.

The requirement was :

A button on an Applet should be enabled if a particular user logs into the application otherwise it should remain disabled.The Solution is a simple script that we can write on Applet_PreCanInvoke event to enable or disable a button conditionally.

I am providing the pseudo code for that script below

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)
{
if (MethodName == "UrButtonMethod")
{
if(UserLogin == "AuthorisedUser")
{
CanInvoke="TRUE";
return (CancelOperation);
}
else
{
CanInvoke="FALSE";
return (CancelOperation);
}
}
}

There is just one catch in the above mentioned code. How will you find that user is the authorised user or not. There are several ways of doing it some are easy and some are difficult.

I will tell you the easiest way to do that. You just need to write one line of code to accomplish that which is as following.

if(TheApplication().GetProfileAttr("Me.Login") == "AuthorisedUserLogin")

There is a whole bunch of such kind of profile attributes that are available to us all the time in the whole application, we can use them anywhere we want. But discussion on Profile Attributes is subject of another post. So, come back for more.

If this post was helpful to you, Please post your comments or suggestions to make this site better.

2 Comments:

chiku said...

thanks for the ansewer.

But to solve this,is scripting the only way out.???????????

Neel said...

Conditionaly enable or disable a button. This is the only way I know. But to just enable a button you don't need scripting you can just use Named Method property.

But if anyone out there knows a better way to do it. Feel free to post it here.

You Might want to read following articles also.