You need to sign in to do that
Don't have an account?
Raghu_dev
Disabling/Enabling scontrol based on a conditon
Hi, I need to disable/enable a scontrol (in this case it is a button) based on some logic(if condition). Please let me know how this can be achieved.
Here is the scenario :
We have a "account change queue" object. This object does store all the change requests submitted by reps and the change request transforms through several stages (nothing but status). During some stages, reps are not allowed to do a "request change" (which is a scontrol button) and hence the page should render with a disabled button based on the status field.
The code looks similar to the following..
<script type="text/javascript">
function setupPage() {
sourceId = '{!Queue_Billing_Profile_Change__c.Id}';
var status = '{!Queue_Billing_Profile_Change__c.Billing_Profile_Change_Status__c}';
if (status == "Under Review")
{
// button should be disabled for the above status.
}
</script>
Thanks
Here is the scenario :
We have a "account change queue" object. This object does store all the change requests submitted by reps and the change request transforms through several stages (nothing but status). During some stages, reps are not allowed to do a "request change" (which is a scontrol button) and hence the page should render with a disabled button based on the status field.
The code looks similar to the following..
<script type="text/javascript">
function setupPage() {
sourceId = '{!Queue_Billing_Profile_Change__c.Id}';
var status = '{!Queue_Billing_Profile_Change__c.Billing_Profile_Change_Status__c}';
if (status == "Under Review")
{
// button should be disabled for the above status.
}
</script>
Thanks
It looks like you have the logic to do this. With the auto format I can't be positive because it has the smile.
Your other option would be:
I might have missed something, I have a hard time working with other's code. Please let me know if you have issues with it.
Message Edited by TCAdmin on 05-12-2008 12:21 PM
Unfortunately it didnt work for me. But I found the reason why it didnt work. As I said earlier, the button on the page is a s-control and the code behind the s-control doesnt trigger unless the button is clicked.
And what I am trying to do is disabling the button on page render.
So, I decided to do a hidden s-control on page (just made height and width as zero) and did put the following code which controls the enable/disable functionality of the button. Please let me know if my explanation didnt really make sense.
And btw, completely off topic question, how did you put your code in a box on your earlier post.
function setupPage() {
sourceId = '{!Billing_Profile__c.Id}';
var status = '{!Billing_Profile__c.Status__c}';
//var reqChng = document.getElementById('00b70000000zDze');
var reqChng = parent.document.getElementsByName('request_change');
alert ("Status from Controller - " + status);
//source.output.innerHTML = status;
if (status == "Pending")
{
reqChng[0].disabled = "true";
}
}
Message Edited by Raghu_dev on 05-13-2008 06:49 AM