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.



8 Comments at "Siebel How To - enable or disable a button conditionally?"
thanks for the ansewer.
But to solve this,is scripting the only way out.???????????
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.
I have a small query for you?
What would happen if we write in else
part of the condition as
return (ContinueOperation);
Will it suffice.
Hi Sriniwas,
I have not tried that but logical looking it should work for this requirement. but the only problem I can see in this if we might want to disable or enable it on the basis of field value.
Then this might create a problem as we know that PreCanInvoke is fired a lot of times even when we are not doing anything.
We take an example where field values result in execution of if statement but then else would never be executed and button will not be disabled once the condition is false
Hi
Sir this s Siva i relay impressed U’R Answers
Sir i have asking one query how to find
W/F Errors. where i can see that errors
ple help me…….
Thanks
Siva
Hi siva,
You can find workflow errors in
Administration -> Server Management -> Tasks
Query for workflow* and you should get list of all the workflows executed.
The information you get will depend on the log level that you have set.
You can read the following post to see how to increase the log level
http://siebelunleashed.com/siebel-crm-workflow-debugging-through-logs/
Hi sir This s siva I have one query when can U use Business services ans W/F policy’s and runtime event particularly ple give some examples
with real time scenario’s ple help me ….
Thnks
Siva
Hi,
This is Mohan. It is good post, Please mail me ur maIL-ID, I have some doubts. My mail id is mohan.sieb[at]gmail.com.
Bye,
Mohan.
Comment Now!