Rajeev Pentyala - Microsoft Power Platform
Let’s take the OOB Account and Contact related entities.
Whenever we click ‘Add New Contact’ button from the ‘Associated view’ of ‘Account’ form, all the mapping fields data would be copied to ‘New Contact’ form.
Account:
New Contact Form:
This is native CRM behavior, to copy the content from Parent to Child record, using the Relationship ‘Mappings’ to avoid the overhead of manual data entry on child record.
What If we have to create a Contact from a console application using CRM SDK and achieve the same behavior? ‘InitializeFromRequest’ is the answer.
Steps to use ‘InitializeFromRequest’:
- Instantiate the ‘InitializeFromRequest’
- Set the Target as ‘Contact’
- Set the ‘EntityMoniker’ as the reference of parent ‘Account’ which you would want to copy the data from
- Execute the ‘InitializeFromRequest’
- From the ‘InitializeFromResponse’, read the Contact object with copied data from Account (**Contact would not be created in CRM at this point**)
View original post 121 more words