You need to sign in to do that
Don't have an account?
Robert Robinson 17
Java Script issue - referencing record type
Java Script issue - referencing record type
I am following up after a consultant that used JavaScript to direct users to 1 of 2 record types from an Account Related List. I have added a 3rd record type, and am trying to create a button that references the JavaScript. Here is the code that I am working with:
{!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.Record_Type_3__c}';
opportunity.StageName = 'Quote in Progress';
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 bold, italicized area is where the error is. The error message is:
<span class="errorStyle">Error: Field Record_Type_3__c does not exist. Check spelling.</span>
Record Type 3 does exist, and the spelling is correct. Is there someplace else that I need to define the "Record_Type_3" field? Thanks.
I am following up after a consultant that used JavaScript to direct users to 1 of 2 record types from an Account Related List. I have added a 3rd record type, and am trying to create a button that references the JavaScript. Here is the code that I am working with:
{!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.Record_Type_3__c}';
opportunity.StageName = 'Quote in Progress';
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 bold, italicized area is where the error is. The error message is:
<span class="errorStyle">Error: Field Record_Type_3__c does not exist. Check spelling.</span>
Record Type 3 does exist, and the spelling is correct. Is there someplace else that I need to define the "Record_Type_3" field? Thanks.
Yes you must define it under SETUP-->Custom Settings-->Opportunity Record Type Ids
Your consultant has created custom settings to maintain all recordtypes under opportunity and $Setup provides access to retrive Custom Setting
I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D