I have the below functionality inside a for loop, the highlighted field is a master field in the child object that is populated in this piece. For the first iteration it populated the value but the second iteration on the same line it throws the Field is not writeable: Forecast_Line_Item__r.Order__c. Any help is much appreciated.TIA

enter image description here

  • Please do not use a screenshot to post code. The {} button in the editor should be used to format code properly.
    – sfdcfox
    Apr 28 '20 at 16:25
  • what is the relationship between Forecast_Line_Item__c and Order ? Apr 28 '20 at 16:26
  • Please edit this post to include code as text. Screen shots are not accessible to users who utilize assistive technology such as screen readers and work poorly on mobile.
    – David Reed
    Apr 28 '20 at 16:47

It seems you are trying to do reparenting (change the parent when it is already associated with another parent record )in the master detail relationship, which is not allowed by default. Refer the link- https://help.salesforce.com/articleView?id=relationships_considerations.htm&type=5 , you can set Allow reparenting option in the master-detail relationship definition.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.