You need to sign in to do that
Don't have an account?

Onclick Javascript Button Issue
I am trying to create a custom button on the Quote page that creates a Sales Request record when clicked.
The Sales Request is a child object and has a lookup to Quote & Opportunity fields.
I keep getting this error: 'Cannot set property 'Id' of undefined'
Any direction would be appreciated. Here's what I have so far:
The Sales Request is a child object and has a lookup to Quote & Opportunity fields.
I keep getting this error: 'Cannot set property 'Id' of undefined'
Any direction would be appreciated. Here's what I have so far:
{!REQUIRESCRIPT('/soap/ajax/30.0/connection.js')} var srq = new sforce.SObject("Sales_Request__c"); srq.Id = "{!Sales_Request__c.Id}"; srq.Quote__r.Id = "{!Quote.Id}"; srq.Quote__r.OpportunityId = "{!Opportunity.Id}"; srq.Status_c = "New"; srq.Type__c = "New"; var result = sforce.connection.create([srq]); if(result[0].getBoolean("success")){ window.location = "/" + result[0].id + "/e"; }else{ alert('Could not create record '+result); }
Please check this if it works :
Thanks,
N.J
All Answers
Please check this if it works :
Thanks,
N.J
Awesome! Thank you, works perfectly! One more clarification, how could I automatically populate the Opportunity field related to the Quote on the object?
I created a lookup Opportunity field but that doesn't seem to work. Any ideas?
Kon
e.g srq.Opportunity__c = "{!Quote.Opportunity}"
If you want to add individual fields from opportunity then you might need to query quote related opportunity to access individual fields.
Thanks,
N.J