You need to sign in to do that
Don't have an account?
Jonas Myhre
Unexpected identifier, custom JavaScript button
Hey, im trying to create a Javascript button that creates a custom object from Opportunity. The code i have so far is probably not the best, i've pasted it below. I get "Unexpected Identifier" error message.
Thanks for help!
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var billing = new sforce.SObject('Billing__c');
{!Opportunity.Name} = "{!Billing__c.Name}";
{!Opportunity.Contact_Id__c}="{!Billing__c.Contact_Person__c}";
{!Opportunity.AccountId}="{!Billing__c.Account_nameId__c}";
result = sforce.connection.create([billing]);
Thanks for help!
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var billing = new sforce.SObject('Billing__c');
{!Opportunity.Name} = "{!Billing__c.Name}";
{!Opportunity.Contact_Id__c}="{!Billing__c.Contact_Person__c}";
{!Opportunity.AccountId}="{!Billing__c.Account_nameId__c}";
result = sforce.connection.create([billing]);
Also, you should use the javascript variable billing you created, and not Salesforce object :
billing.Name = "{!Opportunity.Name}";
billing.Contact_Person__c = "{!Opportunity.Contact_Id__c}";
billing.Account_nameId__c = "{!Opportunity.AccountId}";
You can check on your browser's console that there isn't any javascript error, or try to display result with alert(result);
Then once it work you can easily redirect with the following line :
window.location.href = '/'+result[0].id;
result = sforce.connection.create([billing]);
What is "Beredskap Test Kommune" displayed in the error message ?