is there any equivalent to page.isvalid in crm? RRS feed

  • Question

  • Hello, I'm working on a crm implementation that auto-saves a case form when it opens. This is so the user doesn't have to click the save button before entering associated subgrid data.

    This process disables the required fields before auto-saving and then re-enables the required fields after the save completes.  Therefore, the required fields are enforced when the user tries to update the case form.

    I'm encountering an issue when I try to delete a task from a new case form that's been auto-saved without required fields. Deleting the task causes the PreCaseUpdate plugin to be triggered.  The PreCaseUpdate plugin does some processing based on some of the required field values for the case form. This throws an exception because the required field values don't exist on the case form.

    Since task is a distinct, related entity separate from the case form, I'm surprised that the PreCaseUpdate plugin gets triggered when removing an associated task. Is there any way to prevent the PreCaseUpdate plugin from getting triggered when a case task is removed?

    Also, ASP.NET validators have a server-side validation routine something like Page.IsValid() which allows the code to check if all input is valid before proceeding. Does CRM have any type of equivalent routine?  I could use something like that as a guard clause to address my problem scenario.  Thanks!

    Thursday, February 20, 2014 11:34 PM


All replies

  • CRM provides basic validation on things like required fields, data types, etc... anything beyond that you would need to trap the save event and perform your own logic to validate and then either allow or cancel the save.

    Save Event Arguments Reference

    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Friday, February 21, 2014 2:57 AM
  • you can change your plugin code to avoid exception like key not found by using

    if(entity.contains("field name"))



    in place of directly using your attribute entity.Attributes["field name"]

    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Friday, February 21, 2014 3:58 AM