Create a related record

Badge +2


I was wondering if anyone can help me with this question please.

I have a custom object with master detail relationship with Opportunities.

I would like to create multiple related records for that custom object when I create the opporunity on the same page. Also display a set number of records depending on the opportunity field.

For example when I select the opportunity type = silver then the page needs to display 5 records (rows) of the custom object that need to be filled in and saved.

Can you please guide me to the steps.


This topic has been closed for comments

3 replies

Badge +18

You can technically do this all in the ui with multiple buttons and conditional rendering.
Or you can use javascript.

If you want to stay in the world of point&click, create one button for each set of rows that you need to create, conditionally rendering those buttons based on the opportunity type field. The buttons will be run mulitple actions, and will have consecutive ‘create new row’ actions.

For example, your silver type, your button will have 5 create row actions.

If your gold type needs 7 rows, the button conditionally rendered when the type is ‘gold’ will have 7 createrow actions.

Will that serve your use case?

Badge +2

Thank you Matt! This sounds great.
I was wondering if you can help me with the next question too.
When I try to save my records for the child object it keeps throwing an error that the ID for the parent does not exist. I am pretty sure this is very simple issue and I have read this article:
But I still can’t figure it out.
Thanks for your help.

Badge +2

Hi Matt,

I worked them out. I am now testing the end to end process.

I may come back with some more questions, if you don’t mind.

Thanks for your help!