2

CM_Contract__c is a custom object and Opportunity__c is a lookup field. I am getting the following error:

Cannot read property 'Name' of undefined

Here's my code:

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 
var result = sforce.connection.query("select Name from CM_Contract__c where Opportunity__r.Id = '{!Opportunity.Id}' LIMIT 1");
  • it seems to be correct. can you post your rest of the code ? – Himanshu Mar 7 '16 at 18:21
  • I don't mind but there is lot of custom settings and objects used is it okay? – PranavJain Mar 7 '16 at 18:42
  • 2
    are you sure error on this line ? It seems error is coming at some other place when javascript trying to access value of name attribute – Himanshu Mar 7 '16 at 18:53
  • Agree with @Himanshu, try doing a console.log(result) after your query and you'll probably see that you're not getting any result returned. – Jason Benkert Mar 7 '16 at 19:29
  • @Himanshu I'm very confident that error is in those few lines of code only as I've checked my code without those lines of code and it is working absolutely fine. – PranavJain Mar 8 '16 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.