You need to sign in to do that
Don't have an account?

Button active or inactive based on picklist value
Hi Everyone,
I have a button and picklist field .. I have to keep the button active when the status is A and B and keep it inactive when the status is C. How can I do this? Do I need to write a trigger? Pls help
Thanks
Mukul
I have a button and picklist field .. I have to keep the button active when the status is A and B and keep it inactive when the status is C. How can I do this? Do I need to write a trigger? Pls help
Thanks
Mukul
<head>
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<script>
function btnDisable(label){
setTimeout(function(){
var pick1Text = $('[id$=pick1]').find('option:selected').text();
if(pick1Text=="A" || pick1Text=="B"){
$('[id$=myButton]').prop("disabled",true);
$('[id$=myButton]').addClass('btnDisabled');
}
else{
$('[id$=myButton]').prop("disabled",false);
$('[id$=myButton]').removeClass('btnDisabled');
}
},500);
}
</script>
</head>
<apex:form>
Select Value ::
<apex:inputField id="pick1" value="{!contact.status__c}" onchange="btnDisable(this);"/><br/>
<apex:commandButton value="Click Me" id="myButton"/>
</apex:form>
You don't need to write any trigger.
Thanks.
I already have some script on that button to set a particular value on click..
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var p = new sforce.SObject('Account');
p.id = "{!Account.Id}";
p.Account_Sync_Status__c = "Submitted";
result = sforce.connection.update([p]);
location.reload(true);
Now i need to add script to keep it active when the picklist value is New/Modified and Inactive/greyed out when value is Submitted/Synced.
How would i merge the code with the existing one?
Thanks!!
You are calling asynchronous call that is
result = sforce.connection.update([p]);
and after that you are reloading the page this will immediately reload the page . So you need to set callback in sforce request and that callback will execute the reload code.One more thing you should Set that is session id.
I am posting code that can help you to better understand.
If this post solves your problem kindly mark it as solution.
Thanks.