You need to sign in to do that
Don't have an account?
getSobject() generating error when pulling field value from parent record
We have a custom object Physician__c with a lookup to this object on the Account object. The relationship is 1:many, the field name on the Account object is Primary_Care_Physician__c, and the field is not required.
I'm working on a trigger on the Account object and need to reference some fields on the parent Physician__c object. I figure that the best approach is to use the getSobject() feature.
I'm attempting to reference the field Fax__c on the parent object but am getting the error Invalid relationship Physician__c for Account: Trigger.zUpdateFaxInfo_Account.
As best I can tell my syntax is correct, but obviously something is not right. Help?
I'm working on a trigger on the Account object and need to reference some fields on the parent Physician__c object. I figure that the best approach is to use the getSobject() feature.
I'm attempting to reference the field Fax__c on the parent object but am getting the error Invalid relationship Physician__c for Account: Trigger.zUpdateFaxInfo_Account.
As best I can tell my syntax is correct, but obviously something is not right. Help?
trigger zUpdateFaxInfo_Account on Account (after update) { for (Account acct : Trigger.new) { Account oldacct = Trigger.oldMap.get(acct.ID); String FaxNumber = (String) acct.getSobject('Physician__c').get('Fax__c'); //rest of code will go into here } }
All Answers
James, I think that does it. I just gave it a quick debug test and it looks to do what I need. I'm marking this as the best answer and will work it into my trigger tomorrow.