function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
wilbur07wilbur07 

Urgent Help Needed!

I have a trigger on Asset that writes AssetHistory much like CaseHistory tracks changes in Cases.

I am having trouble assigning a value to the parent field Asset__r.  When I assign Asset__r.Id to a trigger value it says that field is not writeable.  If I assign Asset object from trigger (say Asset a : trigger new) Asset__r=a; then nothing gets written to that field on the trigger event, and the asset history item does not show on related list under the Asset. 

Please tell me a way to assign the correct Asset value, whether Id or Name or what, to the parent field AssetHistory__c.Asset__r field and I will be forever in debt to you.

James
wilbur07wilbur07
Asset__r should be referenced as Asset__c as in Asset__c=a.id.

this works fine!