You need to sign in to do that
Don't have an account?
Custom Button to Change Status and Completed Date
I created a custom button on a custom object and onclick, it should update the status to 'Completed' and the Completed date to NOW(). I tested it in Sandbox and it worked properly, I updated the field id's to Production and it worked the day I deployed it. However it has not worked since I initially deployed it.
Here are the details:
Detail Page Button
Behavior: Display in existing Window without Sidebar or Header
Content Source: URL
/{Setup_Request__c.Id}/e?retURL={Setup_Request__c.Id}&00N70000002jHJ9={!NOW()}&00N70000002jHKl=Completed&save=1
Link Encoding: Unicode (UTF-8)
The only other thing I've found online suggested changing the &save=1 to &save=0, but neither option has worked for me.
Then based on feedback I received in the Answers Community, I tried modifiying the code to some javascript so it would envoke onclick. Every time I click on the button, I receive an error message saying 'Object Expected'. Here is the code I'm using:
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var sr = new sforce.SObject("Setup_Request__c");
sr.id = "{!Setup_Request__c.Id}";
sr.Status__c = 'Completed';
sr.Completed_Date__c = new Date();
result = sforce.connection.update([sr]);
window.location.reload();
Any help is greatly appreciated.
This variables highlighted below is nothing but the HTML values of that fields.
Ensure once if its same.
/{Setup_Request__c.Id}/e?retURL={Setup_Request__c.Id}&00N70000002jHJ9={!NOW()}&00N70000002jHKl=Completed&save=1
However the javascript code you mentioned is appropriate,
Have made some minor changes, check if it helps: