You need to sign in to do that
Don't have an account?
Robert Robinson 48
A puzzler with Java Script buttons after a sandbox refresh
We have a set of JavaScript buttons which are designed to generate new opportunities when a user clicks a button from a related list on an account. These buttons were working as planned yesterday. Overnight, we refreshed our full UAT sandbox from production. This morning, when I try to generate a new opportunity in the sandbox, Salesforce opens up a new page and tries to log in to production. The process then errors out, as the system is trying to create an opportunity in the wrong environment. When you take the ID generated in production, then apply it back to the sandbox, a new opportunity is then created. I have reviewed the JavaScript button, and I see no references to the production org.
Here is one of the JavaScript buttons:
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/31.0/apex.js")} var opportunity = new sforce.SObject('Opportunity'); opportunity.Name = 'Do Not Delete'; opportunity.AccountId = '{!Account.Id}'; opportunity.RecordTypeId = '{!$Setup.Opportunity_Record_Type_Ids__c.Standard_Services__c}'; opportunity.StageName = 'Qualification'; var closeDate = new Date('{!TODAY()}'); closeDate.setMonth(closeDate.getMonth()+6); opportunity.CloseDate = closeDate; var result = sforce.connection.create([opportunity]); if(result[0].success == 'true'){ var serverPrefix = '{!$Setup.Server_Prefix__c.Server_Prefix__c}'; var oppId = result[0].id; parent.window.location.href = 'https://' + serverPrefix + '.salesforce.com/' + oppId; } else{ alert('Record creation failed - please notify system administrator'); }
The Standard Services Opportunity Record ID is in Custom Settings. The Record IDs point to Record types within UAT
Here is one of the JavaScript buttons:
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/31.0/apex.js")} var opportunity = new sforce.SObject('Opportunity'); opportunity.Name = 'Do Not Delete'; opportunity.AccountId = '{!Account.Id}'; opportunity.RecordTypeId = '{!$Setup.Opportunity_Record_Type_Ids__c.Standard_Services__c}'; opportunity.StageName = 'Qualification'; var closeDate = new Date('{!TODAY()}'); closeDate.setMonth(closeDate.getMonth()+6); opportunity.CloseDate = closeDate; var result = sforce.connection.create([opportunity]); if(result[0].success == 'true'){ var serverPrefix = '{!$Setup.Server_Prefix__c.Server_Prefix__c}'; var oppId = result[0].id; parent.window.location.href = 'https://' + serverPrefix + '.salesforce.com/' + oppId; } else{ alert('Record creation failed - please notify system administrator'); }
The Standard Services Opportunity Record ID is in Custom Settings. The Record IDs point to Record types within UAT
The Custom settings would need to be investigated by the sound of it.
your line var serverPrefix = '{!$Setup.Server_Prefix__c.Server_Prefix__c}'; points to the possible source of your issue.
Regards
Andrew
All Answers
The Custom settings would need to be investigated by the sound of it.
your line var serverPrefix = '{!$Setup.Server_Prefix__c.Server_Prefix__c}'; points to the possible source of your issue.
Regards
Andrew