Are you annoyed by having to update Contacts’ details one by one with same content? Here is a task, which is retrieving current Account’s multi Contacts and updates them by Account’s details. This task uses a HTML page with JavaScript, fetches account’s information, finds the relevant Contacts and updates them.
First of all, let us create several necessary web resources in CRM:
1. SDK.REST.js: A reusable, generic library that simplifies asynchronous data operations using the REST Endpoint.
2. json2.js: This file is a public domain library created and distributed by Douglas Crockford.
3. MyJS.js: a JavaScript file that contains all functional codes in it.
4. A HTML page loads our JavaScript and show the process and results of updating.
Next, we add a custom group and a custom button to Account grid, form ribbon and Contact’s subgrid ribbon.
In the grid ribbon, the button is only enabled when a single Account is selected. The User can click and pop up a HTML page to update.
In form ribbon, that button is only enabled when current Account is not new. The User can click and pop up a HTML page to update.
In Contact’s subgrid ribbon, users can SELECT several Contacts or update ALL Contacts without selection.
After we click, a HTML page pops up.
The update button is now available. Once clicked, the following work will be done in the background:
1. Send “retrieve Record” request, receive response and get all the Account fields that need to update.
2. Send “retrieve Multiple Records” request, retrieve active Contacts of this Account.
3. If this Account has several Contacts, send “update Record” request one by one and show in progress bar. When all Contacts are done, close this page.
4. Otherwise, if no contact found, it will show a message and wait for the user to close this page.
In the end, we finish updating those SELECTED or ALL child Contacts. Now, we no longer need to enter the same content for multiple Contacts of an Account. At the click of a button it is all done for you!