Skip to content

Create a new record from a parent record using a Smart Button

Scenario:

You want to create a shortcut button to create a child contact record on the account main form command bar (Rather than the + button on the contact subgrid). You also want to map the values using the default mappings.

Steps:

1. Install the Smart Buttons Solution
2. Open the Ribbon Workbench with a solution containing the Account entity (no sub-components)
3. Drag a Quick JS button, name the button something like 'Create New Contact'
4. Enter the following JavaScript

var entityFormOptions = {
"entityName":"contact",
"createFromEntity": {
  "entityType":"account",
  "id":context.data.entity.getId()}
};

// Open the form.
Xrm.Navigation.openForm(entityFormOptions);

It should look something like the following:



You can use this API to also show the Quick Create Form, or open a Main Form Dialog



Feedback and Knowledge Base