+ Start a Discussion
Christopher DeFilippiChristopher DeFilippi 

Custom Button, Field Update

I am trying to create a button on a custom object so when clicked, it updates a checkbox field on the object. I am not a developer so I am reaching out to the pros! 
JitendraJitendra
There are many ways to achieve this :
1. Using Ajax toolkit - refer this article for sample (http://www.jitendrazaa.com/blog/salesforce/create-and-update-records-using-javascript-button-in-salesforce-ajax-toolkit/) - However you may find problem in future if your organization is going with lightning experience.
2. This is better solution - Create a flow (http://resources.docs.salesforce.com/198/10/en-us/sfdc/pdf/salesforce_vpm_implementation_guide.pdf) -  Use FIeld update element and open Flow from Custom button. This answer might be helpful for you (http://salesforce.stackexchange.com/questions/18581/how-to-update-record-using-visual-workflow).
 
Christopher DeFilippiChristopher DeFilippi

I'm not familiar with the flows but, I found a similar code from another article and revised it to what I need however, it is not working.  The code was built for the opportunity field update.

 

!REQUIRESCRIPT(“/soap/ajax/20.0/connection.js”)}  //soap connection call
 
var newRecords = [];  //declare the varaiable that will hold all the information
 
var coapp = new sforce.SObject(“Completed Application”);  //get the opp your on
coapp.id =”{Application_NameId__c}”; //get the id of the opp
coapp.Completed__c =”Submitted”;                // change a field
coapp.some_field__c ='File_Passed_To_Round_1__c‘) ; //create a custom field on your opportunity object called some field , (make sure it’s a text field).
 
newRecords.push(coapp);            //push the information through
 
result = sforce.connection.update(newRecords); //update the database with the information in the variable newRecords
window.location.reload(); // reload the page
JitendraJitendra
I see Single quotes and double quotes while you copied are not correct. Can you try to type all single and double quotes again ? You can visit these short videos if want to learn flow (http://www.jitendrazaa.com/blog/salesforce/flow-in-salesforce-youtube-video-tutorial/) . First video talks about record update using flow.

Below, I came up with :
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}   
 
var newRecords = [];   
 
var coapp = new sforce.SObject("Completed Application");  
coapp.id ="{Application_NameId__c}";  
coapp.Completed__c ="Submitted";             
coapp.some_field__c ="File_Passed_To_Round_1__c"  ;  
newRecords.push(coapp); 
result = sforce.connection.update(newRecords); 
window.location.reload();