I'm trying to implement a dynamic data service into my practice Maestro form, and it's not working out too well. I've created a dummy service that just returns some hardcoded JSON, and attempted to call it from a calculation rule on a text field.  The script from that rule:

var params = [];
var jsonString = DynamicData.call('BG Practice Dynamic Data', params);
return jsonString;

When I preview the form or render it from TM, it throws this error in an alert box infinite times:

"HTTP POST /maguire/servlet/FormDynamicDataServlet
Service name not set"

 The console then infinitely spits out error messages reading:

ror: [$rootScope:infdig] http://errors.angularjs.org/1.5.8/$rootScope/infdig?p0=10&p1=%5B%5D
at Error (native)
at <anonymous>:11:412
at m.$digest (<anonymous>:149:27)
at m.$apply (<anonymous>:151:113)
at l (<anonymous>:102:322)
at J (<anonymous>:107:34)
at XMLHttpRequest.t.onload (<anonymous>:108:4)(anonymous function) @ VM612:123(anonymous function) @ VM612:95$apply @ VM612:151l @ VM612:102J @ VM612:107t.onload @ VM612:108
VM612:11 Uncaught Error: [$rootScope:infdig] http://errors.angularjs.org/1.5.8/$rootScope/infdig?p0=10&p1=%5B%5D(anonymous function) @ VM612:11$digest @ VM612:149$apply @ VM612:151l @ VM612:102J @ VM612:107t.onload @ VM612:108
https://tm.maestro.avoka.com/maguire/servlet/FormDynamicDataServlet Failed to load resource: the server responded with a status of 400 (Bad Request)


I really have no idea what is happening with this. The name of the service is correct, I double checked. Can anyone provide some insight as to what is causing this behavior?

    CommentAdd your comment...

    1 answer


      There are a number of things wrong with this approach, which I'll go through below. The best way to move forward would be to start a new form, drop in a standard Dynamic Data Button, set it's service name in the properties panel, along with any field mappings for parameters and return results, and use that to test your service. From there, if you wish to build custom code, you can look at the pre-made click rule on the Dynamic Data button and go from there.

      Here are some of your problems:

      First, don't call a Dynamic Data Service in a calculation rule. Calculation rules can run any number of times, which is how the calculated field constantly stays in sync with its dependencies. In your case, it will reissue the call indefinitely, which is why you're seeing repeated errors. A Dynamic Data call should be only be done on an event-type rule, such as click, change, blur and so on, that happen at distinct moments. It's ok in certain situations to use one in a validation rule as well (Maestro validation is asynchronous to allow for this) but bear in mind that validation can also occur multiple times - page change, submit, other fields changing - so make sure your call is quick and idempotent if you wish to use it that way.

      Second, you are sending an array in the parameters part of the DynamicData.call signature. It takes an object, with property keys matching your service parameter names.

      Third, Dynamic Data calls are asynchronous. You are treating it as a synchronous call. Nothing is synchronous in web API calls (languages like Java can fool you into thinking so, due to thread-blocking APIs). The return value of DynamicData.call() is a promise, which you can handle using the standard Promise API - i.e. call it's .then() function passing a response handler. Again, you'll see an example of this in the standard Dynamic Data button.


      1. Brian Gaydon

        Wow, I figured I was doing at least one thing wrong but not three. Thank you for your detailed answer, since there isn't much documentation on best practices at the moment it's really valuable to have these questions answered.

      2. Brian Gaydon

        I've solved my problem except for one issue - an error occurring when I click the DDS button. An alert box is displayed that reads: HTTP POST /maguire/servlet/FormDynamicDataServlet Parameter 'sfmRequestKey' not set I've spoken with Rak and he says this looks like a bug, since that parameter is supposed to be set automatically. In the meantime I'm using Test Mode as a workaround, and in that mode everything works perfectly. What does this situation look like to you?

      3. Ben Warner

        Brian, are you trying to execute the dynamic data call in preview mode? If so, you have to use test mode as this article suggests: https://support.avoka.com/kb/x/CYDOAQ - of course you can always publish the form and then run the dynamic data calls from the published form.

      CommentAdd your comment...