You need to sign in to do that
Don't have an account?
How to call a related field in javascript or Apex?
hi all
We have a Registration object that hangs off Location Accounts. Field on registration is called Billing Account.
All our accounts should have a Parent Account, however, users keep creating Registrations on Location Accounts, OR Parent Accounts.
We are trying to cause an error message to occur when someone tries to submit a Registration that is:
a. attached to a Parent Account; or
b. attached to a Location Account that has no Parent Account.
When we use Force.com explorer and query thusly:
select Billing_Account__r.ParentId from Registration__c where Billing_Account__r.ParentId = ''
We get the desired result.
But when we try to call it in the following code,
alert("{!Registration__c.Billing_Account__r.ParentId}");
it tells us
Error: Field Registration__c.Billing_Account__r.ParentId does not exist. Check spelling.
We get the same error whatever field on that Billing Account we are trying to access.
What are we doing wrong?
Thanks so much for all your help. :)
thanks for your help guys - our developer finally resolved it by creating an Apex class to grab the required properties from the account.
:)
All Answers
actually when u used in the javascript u have to take care about case-senstivity.. when you represent object or field use as they are defined...
I don't think case sentive is an issue here, you must be using any controller , get this value in controler and assign it in a String property
public String BillingAccountParentID {get;set;}
and assign value in BillingAccountParentID after you fetch it.
This will make your code not to fail in security check also as using ID from sObject field leads security failure.
thanks for your help guys - our developer finally resolved it by creating an Apex class to grab the required properties from the account.
:)