You need to sign in to do that
Don't have an account?

problems with Custom Detail Page Button
Hello,
I am working on my first custom Detail page button and am having some problems. I am trying to use the 'execute javascript' option using the 'onClick' event. All I want this button to do is change the value in a field on the record.
The code that I am using is pasted below. It is a modification of some code that I am successfully using in a custom button on a Search Page Layout. When I try to run this, I get a Javascript error saying '<sforce id>' undefined, where <sforce id> is the record id for the record I am currently viewing.
I cannot seem to find ANY code examples of a custom detail page button anywhere. Can anyone help out? I am VERY rusty with Javascript - is my problem a mere syntax/useage error??
Many thanks to the SF community!
Here is the code I am using:
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Session__c");
c.id ={!Session__c.Id};
c.Status__c = "Approved";
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
I am working on my first custom Detail page button and am having some problems. I am trying to use the 'execute javascript' option using the 'onClick' event. All I want this button to do is change the value in a field on the record.
The code that I am using is pasted below. It is a modification of some code that I am successfully using in a custom button on a Search Page Layout. When I try to run this, I get a Javascript error saying '<sforce id>' undefined, where <sforce id> is the record id for the record I am currently viewing.
I cannot seem to find ANY code examples of a custom detail page button anywhere. Can anyone help out? I am VERY rusty with Javascript - is my problem a mere syntax/useage error??
Many thanks to the SF community!
Here is the code I am using:
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Session__c");
c.id ={!Session__c.Id};
c.Status__c = "Approved";
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
try changing update syntax to:
result = sforce.connection.update(newRecords[0]);
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Session__c");
c.id ="{!Session__c.Id}";
c.Status__c = "Approved";
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();