1
0
-1

Hi,

I'm trying to link an auto-complete field to a list of suburbs supported by a certain lending policy.  Currently, my autocomplete field is pointed at an array of the suburbs within a data-field which works, but requires a re-publish of the form each time that list needs to be modified.  Ideally, I'd like to have this array sit within a dynamic data form service that I can update at any time without re-publishing but I'm not sure of the code required to pass an array back to an auto-complete field.  Could you provide some sample code for something such as this and let me know how the autocomplete field needs to be configured to accept it in Maestro? 

As a side question, I note that there appears to be a way to set up test data for testing dynamic data fields in Composer. Is there any such equivalent for Maestro?  Otherwise testing requires publishing to TM each time (as far as I know).

  1. Ben Warner

    Hey Sam, which version of Transact Manager are you on?

  2. Sam Fursdon

    Hi Ben, we've just had TM5 installed.

  3. Ben Warner

    Could you ask the test data question separately please.

CommentAdd your comment...

2 answers

  1.  
    2
    1
    0

    Hey Sam, using a Groovy Dynamic Data service you can store the suburb list in a service parameter. The following sample code uses the Fluent Dynamic Data template and support searching of the suburb list. You can update the suburb list service parameter csv at any time.

     

    import com.avoka.core.groovy.GroovyLogger as logger
    import com.avoka.tm.vo.*
    import javax.servlet.http.*
    import groovy.json.JsonBuilder
    class FluentDynamicData {
    /*
    * Perform Form Dynamic Data service call.
    *
    * returns: REST response text data
    */
    String invoke(SvcDef svcDef, Txn txn, HttpServletRequest request, User user) {
       String searchString = request.getParameter('searchString')?.toLowerCase()
       List<Object> suburbs = []
    String csv = svcDef.paramsMap.suburbListCsv
    if(searchString && csv){
    csv.tokenize(',').each {
    if(it.toLowerCase().contains(searchString)) {
    suburbs << ["suburbName": it]
    }
    }
    }
       return new JsonBuilder(suburbs).toString()
    }
    }

     

    To configure this in Maestro you would use the Autocomplete Field and update the Trigger Property Name and Suggestion List Names properties (under Data Source) to suburbName

    and under DDS Configuration set the Dynamic Data Service Name, then add an input field mapping to point to the auto complete field itself for the search string.

     

    You should then get the following behavior in the form:

     

    Hope that helps.

      CommentAdd your comment...
    1.  
      1
      0
      -1

      Thanks Ben, that's done it!  

      I'll ask the other question separately as you've suggested. 

        CommentAdd your comment...