locked
CRM 4.0: Plugin RRS feed

  • Question

  • Hi

    I need some help with plugin scenario here.

    1. Lets say there is a text Field A on Form FA. 

    2. When I open Update form, value of Field A is Hi.

    3. I change this value to Hello.

    4. Now, Onsave of Form FA, I want to check if value of field A has changed, then do not save the value. So, after save of FA, value of A should still remain Hi. 

    In other words, I do not want user to change value for this field. I think it is similar to checking isDirty in javascript.

    Any suggestions will be helpful.

    Thanks

    Tuesday, February 21, 2012 8:31 AM

Answers

  • Hi,

    Why do you want to solve this with a plugin? It's enough to set the field read only on the form so the user can't change the value...

    If you really want to do this with a plugin you must register the logic of the plugin on event "pre update" (event before persisting in crm database). In your plugin-logic you can load the data which is stored in the crm-database by webservice and compare the value with the given object from the plugin-context. If the values different you can override the value from the plugin-context with the "original" value from the crm-database.

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010

    • Proposed as answer by The Hosk Tuesday, February 21, 2012 9:44 AM
    • Marked as answer by CRMDevlpr Tuesday, February 21, 2012 9:54 AM
    Tuesday, February 21, 2012 9:38 AM

All replies

  • Hi,

    Why do you want to solve this with a plugin? It's enough to set the field read only on the form so the user can't change the value...

    If you really want to do this with a plugin you must register the logic of the plugin on event "pre update" (event before persisting in crm database). In your plugin-logic you can load the data which is stored in the crm-database by webservice and compare the value with the given object from the plugin-context. If the values different you can override the value from the plugin-context with the "original" value from the crm-database.

    Greets,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010

    • Proposed as answer by The Hosk Tuesday, February 21, 2012 9:44 AM
    • Marked as answer by CRMDevlpr Tuesday, February 21, 2012 9:54 AM
    Tuesday, February 21, 2012 9:38 AM
  • I agree with BuAn, i think it would be a lot easier to fix this with Javascript, you could even do it on onChange so they couldn't type in the wrong thing.


    Ben Hosking
    Check out my CRM Blog
    Linked-In Profile
    Follow Me on Twitter!

    Tuesday, February 21, 2012 9:42 AM
  • Hi BuAn and Hoskinator

    Thanks for reply. Yeah its true this can be easily done in onchange of field.

    But there are some reasons and dependencies, which are making this thing to be done on field onchange.

    Tuesday, February 21, 2012 9:54 AM