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

Costom button - execute javascript -Undefined field Error -
I'm trying to create a custom link button with "execute javascript" behavior. I'm getting error on line
var cont = records[0].top_firm__r.Coverage_Channel__c;
Coverage_Channel__c is a picklist type field. Query using dev console does not throw an error and there is a value in that field. Also, I see values by doing the console.log(records ); I'm not quite sure why it throws error "cannot read property 'Coerage_Channel__c' of undefined "
var cont = records[0].top_firm__r.Coverage_Channel__c;
Coverage_Channel__c is a picklist type field. Query using dev console does not throw an error and there is a value in that field. Also, I see values by doing the console.log(records ); I'm not quite sure why it throws error "cannot read property 'Coerage_Channel__c' of undefined "
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")} var result = sforce.connection.query( "SELECT Name,top_firm__r.Coverage_Channel__c " + "FROM Contact " + "WHERE Id = '{!Contact.Id}' " ); var records = result.getArray("records"); if(records.length != 0){ var cont = records[0].top_firm__r.Coverage_Channel__c; window.top.location.href="someting........"; }
Ed055,
I have changed this
var result = sforce.connection.query( "SELECT Name,top_firm__r.Coverage_Channel__c " + "FROM Contact " + "WHERE Id = '{!Contact.Id}' " );
to var result = sforce.connection.query("SELECT Name, top_firm__r.Coverage_Channel__c FROM Contact WHERE Id = '{!Contact.Id}' " );
Please now check case sensitivity...please use same API Name, and be ensure you are following correct name.
Thanks
All Answers
Please use below snippet, It will help you :) [Already Tested]
Please let me know the results :)
Thanks
Rajat maheshwari
rajatzmaheshwari@gmail.com
Rajat - not sure what change you made to my script. looks same to me.
Ed055,
I have changed this
var result = sforce.connection.query( "SELECT Name,top_firm__r.Coverage_Channel__c " + "FROM Contact " + "WHERE Id = '{!Contact.Id}' " );
to var result = sforce.connection.query("SELECT Name, top_firm__r.Coverage_Channel__c FROM Contact WHERE Id = '{!Contact.Id}' " );
Please now check case sensitivity...please use same API Name, and be ensure you are following correct name.
Thanks
Thanks Rajat .