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
Anjana Sharma 9Anjana Sharma 9 

Dynamicaly insert parent record and then insert child records in that parent record

Hello everone ,
I dont understand that how can i get the object dynamically from object like , i have two arguments:-
1.Map<String,List<String>>: Key:Parent Object , Val: List of Child Object
 2.Map<String, Map<String, String>>: Key: Object , Value = Key: Field, Value: Field Value

For example:
In argument i passsed
Account => new List<String>{Contact}
And in argument 2 i passed
Account => new Map<String, String>{Name => Test, website = test.com} Contact => new Map<String, String>{FirstName => Test, FirstName = Last name Test}

i want to insert account then insert all child objct records in that parent account
PriyaPriya (Salesforce Developers) 

Hi Anjana,


Please refer this example and modify yours accordingly :- 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_foreign_keys.htm

Regards,

Priya Ranjan

Anjana Sharma 9Anjana Sharma 9
Thanku for giving response but as i say i have to pass ovject and its record and values from the argument . Can you please help me with this