Has anyone used Form.fireRule in a Page Change rule in Maestro?


I have a Page Change rule, which calls a Dynamic Data service. Based on the response on the Dynamic Data Service, I set some data in the fields on the form. I then want to fire some rules on the form, but it fails.


The code I used to fire the rules are:

Form.fireRule("onSuccess", "data.save3", data, response);
Form.fireRule("onSuccess", "data.done3", data, response);

This fails with We caught an error TypeError: Cannot read property 'id' of undefined.


    CommentAdd your comment...

    1 answer


      Hey Dianna,

      The second parameter should be the a reference to the item with the rule on it or the id of the item with the rule on it.


      So, you in your case the reference to the item would be:


      (without quotes)

      or just the item id in quotes:


      Simplest fix is to remove the "data.", like so:

      Form.fireRule("onSuccess", "save3", data, response);
      1. Unknown User (diana.pattenden)

        Hi Ben Warner thanks for your response. I have tried your suggestion of removing the data, but the rule doesn't get fired.

      2. Unknown User (diana.pattenden)

        Ben Warner I managed to get the rules to fire, but the order of the rules fired is not what I expected.

        It seems to trigger the done3 rule before the save3 button even though I have specified to do the save3 first. Is there any way I can ensure that the order of the rules get fired?

      3. Ben Warner

        Hey Dianna, how good is your JavaScript? I'm no JS expert but I believe you could use promises to achieve what you want. https://spring.io/understanding/javascript-promises If you want the code in one of the onSuccess methods to complete its execution before the other starts you may need the onSuccess method to return a promise.

      CommentAdd your comment...