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
kezia dolakezia dola 

Tigger to update master detail field in custom object

Hi,
I have two objects i.e; Invoice and Account. Invoice is a custom object, in invoice object, I have a master detail field called "customer name__c". I want to populate the customer name field with account name while creating a new record in invoice object. I have tried with process builder and flows to populate the account name but I can't update it.

So, Any suggestion how to update it through trigger?

Thanks,
Kezia
mukesh guptamukesh gupta
Hi Keiza,

As per my underdtand you have a 2 Master detail on Invoice object  that's Account and customer name__c. and you want to display account name in customer name__c field. if i am right then we can't merge in single one because MasterDetail or lookup have Id not concnated string.

so it's not feasible.

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
kezia dolakezia dola

Hi Mukesh,

Invoice is a custom object and it has master detail relationship with account. I want to populate account name in invoice object whenever creating a new invoice record. 

Any suggestion how to do this?

Thanks
Kezia

Deepika GulatiDeepika Gulati

Hi Kezia

You have to add Id field while populating Lookup/Master Detail. 

One Possible way is : 
Create a Record Triggered Flow. Query the Customer record by the name.
Once you have the Id, you can populate that in the Invoice master details field.

Hope this helps. 

Regards

Deepika 
 

kezia dolakezia dola
Hi Deepika,

Thanks for that infromation, but I am new to flows and don't know to how update it through flows. Can you help me with creating a flow?

Thanks
Kezia
Ansunika BeheraAnsunika Behera
Hi Kezia,

We do not need any Trigger here, as Invoice and Account have master detail relationship..whenever we will create a Invoice, there Account name will be mandtory field in that which you need to fill and which will lead you to your solution.

Regards,
Ansunika.Behera
Deepika GulatiDeepika Gulati

Hi Kezia 

As mentioned bu Anusunika, if you are creating from the New button and create screen, it will be a mandatory field. 
But if you creating it through code or batch, we may have to figure the solution accordingly. 

Regards

Deepika