CRM Watcher

CRM Watcher is the source for the latest Microsoft Dynamics CRM News and Downloads.

Sunday, September 17, 2006

Synchronization of Grouped Fields

Nice Post by Philip Richardson:

When a Microsoft CRM Client syncs with the Server it ‘plays back’ the transactions which occurred during the offline state. It only updates attributes which have been changed; it doesn’t overwrite the entire entity.

There are some cases where you want data to be forced onto the Server even if it wasn’t changed offline. One example of this is address updates.

Example: Nancy goes offline.
At 9:52 AM while she is offline she updates Contoso’s postal code.
At 10:15 AM Susan changes Contoso’s entire address.
At 3:15 PM Nancy comes back online and her sync overwrites the postal code only (since it is the only field she changed).

Now we have Contoso’s address data containing a hybrid of Nancy and Susan’s input. Ideally we would want the address to stay consistent – so that the entire address which Nancy had in her system after her 9:52 AM update is written back to the system at 3:15 PM.

Achieving this ‘group update’ is easy in Microsoft CRM by adding an onChange event to each address field. This event tells CRM to submit all the data from the other address fields if the field is changed.

Add this code to every address field’s onChange event:

crmForm.all.address1_line1.ForceSubmit = true; crmForm.all.address1_line2.ForceSubmit = true; crmForm.all.address1_line3.ForceSubmit = true; crmForm.all.address1_city.ForceSubmit = true; crmForm.all.address1_stateorprovince.ForceSubmit = true; crmForm.all.address1_postalcode.ForceSubmit = true; crmForm.all.address1_country.ForceSubmit = true;

Read more on Philip Richardson's Blog