You need to sign in to do that
Don't have an account?
klocwork
Unexpected Identifier error in JavaScript button
I am spinning my wheels on this and completely stumped. When I try this code I get "A problem with the OnClick JavaScript for this button or link was encountered: Unexpected identifier".
What I am trying to do is update a custom object (Sales_Cycle__c) and the Lead record that it relates to (Sales_Cycle__c.Lead__c).
Any help would be greatly appreciated!
Thank you.
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")} var CycleUpdate = new sforce.SObject("Sales_Cycle__c"); var l = SELECT Id, Status FROM Lead where Id =\'"+ CycleUpdate.Lead__c + "\' limit 1"; CycleUpdate.Id='{!Sales_Cycle__c.Id }'; CycleUpdate.Sales_Cycle_Status__c = 'No Further Interest'; CycleUpdate.Date_Sales_Cycle_Ended__c = new Date(); l.Status = 'No Further Interest'; update CycleUpdate; update l; window.location.reload();
var cycle = new sforce.SObject("Sales_Cycle__c")
cycle.Id = '{!Sales_Cycle__c.Id}'
var lead = new sforce.SObject("Lead")
lead.Id = '{!Sales_Cycle__c.Lead__c}'
cycle.Sales_Cycle_Status__c = 'No Further Interest'
cycle.Date_Sales_Cycle_Ended__c = new Date()
lead.Status = 'No Further Interest'
var result = sforce.connection.update([cycle])
result = sforce.connection.update([lead])
window.location.reload()
Note that you really should check the results to see if the save was successful, this is only for illustrative purposes.
All Answers
var cycle = new sforce.SObject("Sales_Cycle__c")
cycle.Id = '{!Sales_Cycle__c.Id}'
var lead = new sforce.SObject("Lead")
lead.Id = '{!Sales_Cycle__c.Lead__c}'
cycle.Sales_Cycle_Status__c = 'No Further Interest'
cycle.Date_Sales_Cycle_Ended__c = new Date()
lead.Status = 'No Further Interest'
var result = sforce.connection.update([cycle])
result = sforce.connection.update([lead])
window.location.reload()
Note that you really should check the results to see if the save was successful, this is only for illustrative purposes.
Many of your answers have got me out of jams in the past - and happy to have your help direct on this.