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

Traversing look-up field relationships in Javascript.
I have button for an opportunity on which I have the following javascript for an onclick event. Can I not use cross-refrence look-ups in javascript like can in validation rules.
if( {!Opportunity.Account.Name} == 'xxx' ) {
alert('This account cannot be created !');
}
Error: Field Opportunity.Account.Name does not exist. Check spelling.
My original intent was to use a custom object like so ...
if( {!Opportunity.Contract__r.status__c} == 'xxx' ) {
alert('This contract name cannot be created !');
}
Any help would be appreciated ! Thanks !
If you want to access Cross reference record Data in Javascript,
Simply use Ajax toolkit and get the Parent record by SOQL
and Validate it
Thanks,
Bala
All Answers
In my opinon, you can’t use cross object reference in java script for custom button. You should use validation rule to validate lookup field. You can access reference object’s fields there.
Hope this helps.
If you want to access Cross reference record Data in Javascript,
Simply use Ajax toolkit and get the Parent record by SOQL
and Validate it
Thanks,
Bala
Thanks! I guess both these solutions would work.
I just added the fields that I wanted as formula fields and then added it to the js validation.
If solution work for you,
Then please accept particular Post as solution and Helps our community
Enjoy with SF
Thanks,
Bala