While attending a cross product planning meeting earlier in the week an offline scenario was mentioned. I didn’t mention it at the time but I was pretty sure that the CRM could already handle it.

When CRM offline client syncs with the server it ‘plays back’ the transactions which occurred during the offline state. It only updates attributes which have been changed – ie. 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.

Nancy (our sales rep) goes offline. At 9:52 AM while she is offline she updates Contoso’s postal code (in this case she adds the US post code suffix). At 10:15 AM Susan (our order processor) 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 very easy in CRM. We simply add 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. We use the onChange event (not the onLoad event) as only want to submit these fields if one changes. Simply 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;

This posting is provided "AS IS" with no warranties, and confers no rights.

Tags: