Add a button to create a new related record

By | August 28, 2011

To create a new record for a related entity we need to move to that related entity view in the Main form and then use the add button there to actually open a new form for the related entity. At times this is considered time consuming and it would be good to have a button on the main form from where we can add a new related record directly.

While it is easy to add a button to call a new form, we just need to pass in the URL of the new form which is similar to the below

“http://mycrm/myOrg/main.aspx?etn=account&pagetype=entityrecord”

But what differentiates a new record from a new related record is that in related record, the common fields and mappings from the parent record are auto-filled when the new form is opened. The above URL will not copy the mapping fields from the parent record.

To open a new related record form you need to use the following url

var url = Xrm.Page.context.getServerUrl()+”main.aspx?etn= “+Child entity schema name+” &extraqs=%3f_CreateFromId%3d”+ parentRecordId +”%26_CreateFromType%3d”+Parent Entity type code +”%26etn%“+Child entity schema name+” &pagetype=entityrecord”;

Hopefully this little trick would let you minimize a few clicks!

Leave a Reply