function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ankushankush 

Jquery to check a particular value of picklist and update

I have a scenario where a custom button updates the value of picklist to a particular value when ever the button is clicked. The code was working fine. But had another requirement to have this custom button only work when the picklist values are not any value for two particular values. Hence I used the if condition but it is not working. Can some one guide me where I am going wrong.

Withouth the line in bold it is working for all picklist values but as informed above if I want to work only for particular two picklist I tried the statement in bold which is not updating anything.

{!requireScript("/soap/ajax/32.0/connection.js")} 
var er = new sforce.SObject("FC_Reviewer__External_Review__c"); 
er.id = "{!FC_Reviewer__External_Review__c.Id}"; 
if(er.FC_Reviewer__Status__c == "Ready To Review" || er.FC_Reviewer__Status__c== "Review In Progress") 
er.FC_Reviewer__Status__c="Review Submitted"; 
result = sforce.connection.update([er]); 
window.location.reload();
Tejpal KumawatTejpal Kumawat
Hello Ankush,

You need to query first, like code may be this work in your org...
 
{!requireScript("/soap/ajax/32.0/connection.js")} 
var myquery = "SELECT Id, FC_Reviewer__Status__c FROM FC_Reviewer__External_Review__c WHERE Id = '{!FC_Reviewer__External_Review__c.Id}' limit 1"; 
result = sforce.connection.query(myquery); 
records = result.getArray("records"); 
var er = records[0];
if(er.FC_Reviewer__Status__c == "Ready To Review" || er.FC_Reviewer__Status__c== "Review In Progress") 
er.FC_Reviewer__Status__c="Review Submitted"; 
result = sforce.connection.update([er]); 
window.location.reload();


If this answers your question mark Best Answer it as solution and then hit Like!



 
ankushankush
Hi Tejpal,

            Thanks for the help and guidance but no update is happening yet even after we click the button the picklist value is not getting changed.