locked
CRM 2011 Workflow doesn't trigger on JS fieldchange RRS feed

  • Question

  • Hi,

    I have the weirdest issue at the moment. We have a workflow that triggers on a field change and if I use one field, a optionset, it triggers when I change that with a script. That wasn't a good design though since many different actions change the optionset. I changed the workflow to trigger on a bool field change instead, now things get intrersting. When the JS alters the bool field, nothing happens, however if I manually change the bool field the workflow triggers. I have tried to add "Xrm.Page.getAttribute("bool").setSubmitMode("always");" to the JS but that doesn't help. 

    There are no error in the trace files, the thing just fails to trigger.

    Any ideas?

    Thanks!


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, July 16, 2014 1:42 PM

Answers

  • I think I have found the problem, posting here if anyone has a similar problem.

    The entity (a custom entity) have a optionset that is set by the same script that was updating the bool I wanted the workflow to trigger on. Then a plugin preformed a number of tasks regarding on what the optionset was set to. In the end the optionset was nulled by an update in the post operation stage.

    This update was done on the target from the context which had the property bag emptied with a "target.Attributes.Clear();"-call and then the optionset attribute was added to that.

    When I changed that code part to set up a new empty record with id and logical name taken from the plugin target and then adding the optionset field to that object the workflow started triggering. Very weird.

    I did also change the code to not update the record and get another save to the database, don't know how much I will save on it but it's neater at least. (not my code to start with)

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Monday, August 11, 2014 1:19 PM

All replies

  • Hi,

    This gets even weirder. I've tried different approaches to triggering this workflow. I've tried to update the field with a script, and with a plugin. When I change the field with a script the workflow doesn't trigger, when I change the field with a pre execution state plugin the workflow doesn't trigger. If I instead change it with a post execution state plugin and update the record, the workflow triggers TWICE.

    Have anyone seen anything similar?

    Really confusing...

    (edit, there are no errors in any logs)

    Thanks


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se


    Monday, August 11, 2014 10:21 AM
  • I think I have found the problem, posting here if anyone has a similar problem.

    The entity (a custom entity) have a optionset that is set by the same script that was updating the bool I wanted the workflow to trigger on. Then a plugin preformed a number of tasks regarding on what the optionset was set to. In the end the optionset was nulled by an update in the post operation stage.

    This update was done on the target from the context which had the property bag emptied with a "target.Attributes.Clear();"-call and then the optionset attribute was added to that.

    When I changed that code part to set up a new empty record with id and logical name taken from the plugin target and then adding the optionset field to that object the workflow started triggering. Very weird.

    I did also change the code to not update the record and get another save to the database, don't know how much I will save on it but it's neater at least. (not my code to start with)

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Monday, August 11, 2014 1:19 PM