You need to sign in to do that
Don't have an account?
TedLiu
dynamic biding of reference field
Hi All, I need some help with
Myobject__c c = new MyObject__c();
c.put('carrier__c', 'xyz'); // This works
c.put('Name__r.lastName__c', null); // THIS DOES NOT WORK when I view it through my VF page I get invalid field. For some reason REFERENCE to another field from other object does not work
In developer console when I run query like Select Name__r.lastName__c From Myobject__c where id..... I can access Name__r.lastName__c
Myobject__c c = new MyObject__c();
c.put('carrier__c', 'xyz'); // This works
c.put('Name__r.lastName__c', null); // THIS DOES NOT WORK when I view it through my VF page I get invalid field. For some reason REFERENCE to another field from other object does not work
In developer console when I run query like Select Name__r.lastName__c From Myobject__c where id..... I can access Name__r.lastName__c
To bind values using relationship fields you should use the putSObject method instead.
Here is an example:
Please refer to:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm#apex_methods_system_sobject (http://https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm#apex_methods_system_sobject)
Hope to have helped!
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
To bind values using relationship fields you should use the putSObject method instead.
Here is an example:
Please refer to:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm#apex_methods_system_sobject (http://https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm#apex_methods_system_sobject)
Hope to have helped!
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.