You need to sign in to do that
Don't have an account?
Edit Custom Button Java Script
I have a custom button that requies Users to provide reasons for closing an Account. I would like to omit two specific record types form this Java script so we can update the TYPE of Account. We currently are "stopped" from updating th TYPE field because of the Java scipt. Here is the script:
Account Custom Button or Link: Close Prospect ~ Salesforce - Enterprise Edition{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js") }
var leads = new Array();
leads[0] = new sforce.SObject("Account");
leads[0].id = "{!Account.Id}";
var _return = window.confirm('Are you sure you want to begin closing this Account?\nSelect Yes to start the closing process.');
if(_return)
{
var T = "{!Account.Type_Number__c}";
var curDate = new Date();
if(T == 1)
{
var curDate = new Date();
leads[0].RecordTypeId = "012500000009VUN";
}
else
{
alert("The 'Close Prospect' button is only for Prospect accounts. For Live accounts, please create an 'Archive' record at the bottom of the page and follow the archival steps. You can manually change the 'Type' of the account from Live to Archived.");
}
var result = sforce.connection.update(leads);
if (result[0].getBoolean("success"))
{
// Refresh window
window.location.reload();
}
else
{
alert("Request to close this account has failed. \n \nMake sure that you have filled the minimum information required to edit an Account. You can test this by editing a field and attempting to save the account record. \n\n If you can edit and save the account but still see this error, please contact your Salesforce Administrator.\n\nError code 'Acct_Close_1'");
}
}
Account Custom Button or Link: Close Prospect ~ Salesforce - Enterprise Edition{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js") }
var leads = new Array();
leads[0] = new sforce.SObject("Account");
leads[0].id = "{!Account.Id}";
var _return = window.confirm('Are you sure you want to begin closing this Account?\nSelect Yes to start the closing process.');
if(_return)
{
var T = "{!Account.Type_Number__c}";
var curDate = new Date();
if(T == 1)
{
var curDate = new Date();
leads[0].RecordTypeId = "012500000009VUN";
}
else
{
alert("The 'Close Prospect' button is only for Prospect accounts. For Live accounts, please create an 'Archive' record at the bottom of the page and follow the archival steps. You can manually change the 'Type' of the account from Live to Archived.");
}
var result = sforce.connection.update(leads);
if (result[0].getBoolean("success"))
{
// Refresh window
window.location.reload();
}
else
{
alert("Request to close this account has failed. \n \nMake sure that you have filled the minimum information required to edit an Account. You can test this by editing a field and attempting to save the account record. \n\n If you can edit and save the account but still see this error, please contact your Salesforce Administrator.\n\nError code 'Acct_Close_1'");
}
}
Note, you have to be careful with hard coding the Ids, as they might and likely will change between environments / sandbox refreshes.