2
1
0

I'm building a collaboration job where I need conditional form prefill.

When job step = "Start", form prefill is required (prefill service gets data from our back end system). Prefill service uses request parameters to define required data.

If job step != "Start" form prefill is not required. No data is required from the back end system.


Is this scenario possible?

In the prefill service there is no 'txn', so I can't get any job details, and also the job context is not available.

I'm thinking of adding another request parameter such as "start", which would be set to 'true' for the initial job start, and not provided (or set to false) for the other job steps.

This seems a bit clumsy, but is the only combination that I can think of that covers all the possiblities.

If there are any other approaches that are more elegant, or based on the job characteristics, I'd be happy to hear about them.

Any feedback would be much appreciated.


Thanks

Mark

  1. Larry Bunton

    Can I get you to add Collaboration to the list of tags.

    Thanks, Larry

CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    Hi Mark,

    Good question.

    You are correct the Job Context is injected into the form xml when it is rendered and hence not available to the the prefill service.

    The  JobTaskAssignService lets you specify a Action Property where the Task Type is 'Form' (Authenticated)  or 'Anonymous'. You can invoke a Groovy Service or a Fluent Service to do the lookup on the 3rd party system.

    Task Input XML Prefillthe input pre-fill data XML which is mapped into the form XML data using prefill input XPath mappings. This property value is ignored for 'Anonymous' Task Types.{ "name": "Task Input XML Prefill", "value": "$func.invoke('Job Prefill Service', $job)" }

    So your 'Start' step may look like this
    _____________________________________________________________________________

    {
      "name": "Start",
      "type": "",
      "actions": [
         {
            "name": "Start Application",
            "type": "Job Task Assign",
            "preCondition": "$formDataMap.productCreditCards == 'true'",
             "redirectNext": true,
             "properties": [
                 { "name": "Task Assign User", "value": "$func.startUser()" },
                 { "name": "Task Form Code", "value": "aformcode" },
                 { "name": "Task Message", "value": "Please complete the start application form." },
                 { "name": "Task Subject", "value": "Complete Credit Card Application" },
                 { "name": "Task Input XML Prefill",
                   "value": "$func.invoke('prefill service',$func.stepOrStartSubmissionXml(), $job)" },
                 { "name": "Task Type", "value": "Form" }
               ]
             },
             {
               "name": "Review Wait",
               "type": "Job Task Wait"
             }
             ...

    __________________________________________________________________________

    1. Mark Murray

      Hi Larry,

      thanks for that suggestion; I'm still learning about the features of collaboration jobs, and there is a lot there. That looks like a much more elegant approach than what I have so far.

      If I use the above approach to specify the prefill as part of the job, do I also need to 'not' specify anything for the for services prefill? Then when subsequent job steps are invoked the form will not require any prefill.


      Thanks


    2. Mark Murray

      Hi Larry,

      I've tried a couple of options, but get a validation error on the job definition.

      If I use the code as follows:

      { "name": "Task Input XML Prefill", "value": "$func.invoke('Add Signatory Prefill',$func.stepOrStartSubmissionXml(), $job)" }

      the error is:

      ... service 'Add Signatory Prefill' is not a Groovy Service type.

      If I use the code:

      { "name": "Task Input XML Prefill", "value": "$func.invoke('Form Prefill',$func.stepOrStartSubmissionXml(), $job)" }

      the error is:

      ... service 'Form Prefill' not found.

      SO, it seems like I shold use the actual service name, but the system is not recognised as a Groovy service.

      Any ideas?


      Thanks

      Mark

    3. Larry Bunton

      "f I use the above approach to specify the prefill as part of the job, do I also need to 'not' specify anything for the for services prefill? Then when subsequent job steps are invoked the form will not require any prefill."


      Correct.

      cheers

      Larry

    4. Larry Bunton

      You will need to create a Fluent - Groovy Service named 'Form Prefill'

      Here is some code to get you started

      _______________________________________________________________________

      import com.avoka.tm.util.*
      import com.avoka.tm.vo.*
      import javax.servlet.http.*


      public class CollaborationJobPrefill
      {

      // Injected at runtime
      public Logger logger;

      /*
      * Perform a groovy service invocation
      *
      * return: the result object
      */
      Object invoke(SvcDef svcDef, HttpServletRequest request, User user, Map params) {

      logger.debug("params: " + params)
      List arguments = params["args"]
      String xmlData = (String) arguments[0]
      Job job = (Job) arguments[1]

      String result;
      // Your code here
      ...

      return result
      }

      }

    CommentAdd your comment...