1
0
-1

I am trying to create a dynamic data call using Dynamic Data Button. Groovy code has been written and connection has been made. i can hit the Groovy service also successfully. But cannot able to return the value. Below is my Groovy Part

def data ="fimpidsample"
logger.info "data :"+data
def jsonResponse = new JSONSerializer().toJSON(["fimpidr":data]);

return jsonResponse;

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Are you using the Transact Fluent SDK?

      I suggest you change JSONSerializer to groovy.json.JsonBuilder:

      def data ="fimpidsample"
      logger.info "data :"+data
      def jsonResponse = new JsonBuilder(["fimpidr":data]).toString()
      return jsonResponse;

       

      If you are not getting the response you expect, you may want to check the System > Error Log on Transaction Manager.

      Also check out this article on debugging: Advanced Debugging of Maestro Forms

      1. surendarvel

        Thanks Ben i can able to get the data

         

      CommentAdd your comment...
    2.  
      2
      1
      0

      Your Json does not look correct.  It should be more like: [{"fimpidr":data}] or {"fimpidr":data}.

      Also, are you treating the return value from DynamicData.call as a Promise?

      You will need to have something like this in your form:

      DynamicData.call("SomeService", {"someParam": "someValue"})
          .then(function(response) { data.$someData = response; })

      1. surendarvel

        Thanks Much for the help Bill, 

        But i am facing difficulty when assigning the value from the response to the form objects.

        I tried with below code but i couldnt get the values assigned.please help on this.

        DynamicData.call("sample",{"data":"sam"}).then(function(response){

        alert("done"); 

        alert(response);

        Form.setFieldDataFromResponse(data.text1, response, data);

        });

         

         

         

         

      2. Bill Frost

        You're welcome.

        Instead of 'Form.setFieldDataFromResponse(data.text1, response, data);', you probably just want something like:

        data.text1 = response;

        ... assuming your dynamic data call returned a string value in response.

        If response was an object with a property of, say, 'value', you would do:

        data.text1 = response.value;


      CommentAdd your comment...