locked
Update Contact entity based on picklist choice from custom entity RRS feed

  • Question

  • I have been searching through the forum topics and have not found anything that matches/is similar of what I am trying to acheive.

    I have a picklist on a custom entity with three values: "Email" (value = 1), "Letter - Home" (value = 2), and "Letter - Business" (value = 3).  I have altered the Contact entity to have a one "Primary" address and one "Other".  Based on what is chosen in the picklist, I would like to update the Contact entity's addresses.  So--if "Letter - Home" is chosen on the custom entity, then on the Contact entity, all the "Primary" address fields will fill with the Home address information.  If "Letter - Business" is chosen on the custom entity, then on the Contact entity, all the "Primary" address fields will fill with the Business address information.  Does this make sense?

    I am somewhat new to CRM, but I have been working with javascript recently.  I realize that what I am trying to do may be carried out via a workflow, but I think that javascript might be sleeker.  If someone could help me out to get me started, I think I can figure out the rest.  I am guessing that updating it will have to do with either the Contact entity's GUID or its Object Type Code.  As always, I appreciate any help.  Thanks!

    Tuesday, December 7, 2010 5:38 AM

Answers

  • There are some toolkits available for CRM that make SOAP from JS rather easy:

    http://danielcai.blogspot.com/2010/05/mscrm4-web-service-toolkit-for.html

    http://crmentropy.blogspot.com/p/crm-javascript-library.html

    The nice thing about JS over Workflows, are the immediate, synchronous results.  You should consider, however, putting the code to call an update to the contact into the form's OnSave() event, rather than the field's OnChange (so that way you reduce the number of calls to update the Contact, and only when necessary).

    The downside to JS, however, is that you really have no way of identifying whether the save operation failed (I suppose you could call two updates to work around this: one to the custom entity for the selected attribute, and a follow-up for the Contact; pending success upon the first), so it's possible that you can update the Contact, but the value upon the custom entity will reflect something different.  In this way, a Workflow is superior.

    However, if you need immediate results and confidence in data integrity, a Plug-in is generally the way to go.


    Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com Please follow the forum guidelines when inquiring of the dedicated CRM community for assistance.
    Tuesday, December 7, 2010 8:22 AM
    Moderator