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
balakrishna mandula 6balakrishna mandula 6 

Picklist field in formula expression

Hi,
 I have two picklist fileds called Approval Status with Values "Committed, Approved" and Proposal Type with values "Quote and Order" on same object. 
And I have custom button called Convert To Order on detail page, if I click on Convert to Order but it should check with Approval Status field if it is having field value is Approved then Proposal Type should be changed to Order value.
for this I have created a custom button and added JavaScript OnClick event as below. 

{!IF( ISPICKVAL( Custom_Object__c.Approval_Status__c , 'Approved'),
       TEXT( Custom_Object__c.Proposal_Type__c )='Order' ,'Quote')}

But it's not working when I click the button
Best Answer chosen by balakrishna mandula 6
Raghu nathanRaghu nathan
Try this out.. I have used it in the Account object

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')} 

var acct = new sforce.SObject('Account'); 
acct.Id = "{!Account.Id}"; 
acct.Approval_Status__c = "{!Account.Approval_Status__c}"; 
if(acct.Approval_Status__c == 'Approved') 
acct.Proposal_Type__c = 'Order'; 
else 
acct.Proposal_Type__c = 'Quote'; 
sforce.connection.update([acct]); 
window.location.reload();

All Answers

Raghu nathanRaghu nathan
Try this out.. I have used it in the Account object

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')} 

var acct = new sforce.SObject('Account'); 
acct.Id = "{!Account.Id}"; 
acct.Approval_Status__c = "{!Account.Approval_Status__c}"; 
if(acct.Approval_Status__c == 'Approved') 
acct.Proposal_Type__c = 'Order'; 
else 
acct.Proposal_Type__c = 'Quote'; 
sforce.connection.update([acct]); 
window.location.reload();
This was selected as the best answer
balakrishna mandula 6balakrishna mandula 6
Thanks a lot Raghunathan, it's working fine!