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
immaimma 

Create a workflow to update a Master-Detail Relationship field

hello all 
I have tow objects Campaign and Prospect ( campaign is the master and prospect the detail)
and I want to create a work flow rule to update a Master-Detail Relationship field " Campaing " in the object prospect ( if the name of prospect = "aaa" then affect the prospect to the campaign with the name : "campaignaaaa"
when I try to create a work flow rule to update a Master-Detail Relationship field " Campaing " , the field Campaing doesn't appear in the section : " Field to Update" !!! is this beacause "Campaing"  is Master-Detail Relationship field ????
What can I do ? and why the master detail relationship is a required field ??? 
Pankaj_GanwaniPankaj_Ganwani
Hi,

We cannot update either master detail or lookup relationship field using workflow rule. You will have to use trigger approach instead.
immaimma
okey but what about " Process Builder " do you have any idea about it ,,???
Because I don't have any exprience with trigger so I have to think about an existing solution
https://www.youtube.com/watch?v=XgjlPWaElRc
immaimma
I tried with Process Builder but is the some problem :( ,, an other question : is the master detail relationship always a required field ???
Pankaj_GanwaniPankaj_Ganwani
Hi,

Yes, master detail is always a required field.
immaimma
Ok thank you a lot ! 
Pankaj_GanwaniPankaj_Ganwani
Hi,

Process builder will also not work since we will have to perform SOQL to fetch the Campaign record where Name = 'Campaignaaaa' and then populate the respective Id to master detail field.

Please let us know if you need any assistance for the creation of trigger.
immaimma
Thank you a lot.About a trigger I don't think I could do any thing because I have never created a trigger !!!! If you could help about it I would be very grateful 
Suraj Tripathi 47Suraj Tripathi 47
Hi,
Greetings!

First of all, Master-Details field is mandatory. So you can not leave it as a null.
And if you want to update the parent object, Please use Apex triggers, which will help you to update the parent object.
Because in a trigger you can perform SOQL query and fetch the information of the record up to three-level.

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi