Skip to main content
I am writing a custom button on a custom object to trigger a process builder.

 

here is my code

 

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

 

{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} 

 

var records = sforce.connection.query("SELECT Id, [!alumni__c].Process_Builder_Trigger__c FROM Account Where id = '[!alumni__c].id'"); 

 

var accountRec = records.getArray('records')[0]; 

 

 Number(accountRec.Process_Builder_Trigger__c)

 

accountRec.Process_Builder_Trigger__c = Number(accountRec.Process_Builder_Trigger__c) + 1; 

 

sforce.connection.update([accountRec]); 

 

window.location.reload();

 

The object is called Alumni__c as the api name. The builder is saying the syntax is correct but I am getting an unexpected token error for SELECT id please help

 

March 31, 2020·Answer·Like0·Following0·Flag

 

Delete

 

Nicholas ElserNicholas Elser

 

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

 

{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

 

var records = sforce.connection.query("[Alumni__c]id, [alumni__c].Process_Builder_Trigger__c FROM Alumni__c Where id = 'alumni__c.id'");

 

var alumni__c = records.getArray('records')[0];

 

Number([alumni__c].Process_Builder_Trigger__c)

 

[alumni__c].Process_Builder_Trigger__c = Number([alumni__c].Process_Builder_Trigger__c) + 1;

 

sforce.connection.update([accountRec]);

 

window.location.reload();

 

I tried it this way as well 
2 answers
0/9000