1
0
-1

I am trying to setup a collaboration controller for a maestro form. I am having trouble selecting routes after the initial submission. I can only seem to get a default route working, but there are two available routes.

I tried using the "Conditional Route Name" property, but this doesn't seem to work on "Job Form Start", it just ignores it uses the default route.

I tried using Form.setSystemData("Job.RouteName", 'Final'), but this doesn't seem to do anything for me.

I tried binding to the RouteName node, but that is in SFMData and currently there is a bug that doesn't let us bind stuff to SFMData properly (It will create the node but the calculated value doesn't get stored there, we raised a ticket for this)

I tried using a data extract in the default path like: 

{ "name": "Default",  "nextStep": "${formDataMap.RouteSelect}" }

But it wouldn't save because it complained that it wasn't a valid route.

 

What can I do??

  1. Larry Bunton

    As of Transact 17.10 release you can now use the Conditional Route Name in the Job Form Start for the initial submission

    The workarounds as per my response below are still required for older versions of Transact 5.1.X and earlier.

    cheers

    Larry

CommentAdd your comment...

5 answers

  1.  
    2
    1
    0

    Hi Patrick,

    "I tried using the "Conditional Route Name" property, but this doesn't seem to work on "Job Form Start", it just ignores it uses the default route."

    The "Conditional Route Name" is not currently a property of the Job Form Start action service. It only applies to Job Task Form Create action service. There is however a current Feature Request to add it.

    I have a bit of background below and have 2 suggested workaround for you.

    When a form is first filled out it does not have the Job Context (Discussed below) injected from Manager. The reason is that the job isn't created until after the form is submitted. So there isn't any available routes to display. 

     

    1. Client Side - Conditional Route Assignment

    Create a Tools> Data Route

    Note the start step would have to have Approve, Reject and Default as routes.


    2. Server Side

    What we need to setup is a Job Form Start Action and then a Groovy Job Action that does the routing. 

      "steps": [
        {
          "name": "Application Start",
          "type": "start",
          "actions": [
            {
              "name": "Accept Quote",
              "type": "Job Form Start",
            },
            {
              "name": "Conditional Route",
              "type": "Job Action",
            }
          ],
          "routes": [
            { "name": "Approve",  "nextStep": "Application Accept" },
            { "name": "Reject",   "nextStep": "Application Reject" },
            { "name": "Exceeds Threshold",  "nextStep": "Application Review" }
          ]
        }, 

    Its important that the form does not write the decision to the SystemData.JobRouteName we this to be empty.


    In the Form add a standard dropdown field with to a data extracts "Start Route" and "Amount" 

     

    In the "Conditional Route" groovy service we return an ActionResult with a route name

    class FluentJobActionService {
        /*
         * Perform a job action service invocation
         *
         * return: the job action result
         */
        ActionResult invoke(SvcDef svcDef, Job job, JobAction jobAction, HttpServletRequest request, User user) {
    
            Txn txn = Jobs.getStartTxn(job)
    		String route = txn.formDataMap.startRoute
    
            if ( route = "Approve" && txn.formDataMap.amount > 20000) {
                route = "Exceeds Threshold"
            }
    
            return new ActionResultBuilder()
                .setStatus('Completed')
                .setRoute(route)
                .setMessage('Action completed')
                .build()
        }
    } 

     

    Background

    For background information can you please read the Collaboration Jobs Form Design page. Look at the Job Context Information in particular the AvailableRoutes in the bottom table.

     

      "routes": [
        { "name": "Approve",  "nextStep": "Application Delivery" },
        { "name": "Decline",  "nextStep": "Applicant Update" },
        { "name": "Exceeds Threshold",  "nextStep": "Additional Review",  "display": "false" },
        { "name": "Terminate",  "nextStep": "Terminated Initial" }
      ]

     

    If you use a Collaboration >> Route Select widget
    When the form is at the "Initial Review" stage the AvailableRoutes=Approve|Decline|Terminate
    These 3 routes will be populated into the drop down.
    You don't have to do anything to have these populated.
    Collaboration Jobs maps a Route Name to the NextStep.
    Note the NextStep is the name of the step that it routes to. This can't be a template, it is a static string, the result is a static map of routes to steps.
    Sometime you may want to use a radio buttons for selecting the route. In the example below the AvailableRoutes: Update|Terminate
    Create a Radio Button where the name of the buttons is the same as the route.
    In a Change rule you can use the following
    Note these are part of the Step By Step Examples found in the Collaboration Jobs documentation.
    Cheers
    Larry Bunton
    Collaboration Jobs Lead
      CommentAdd your comment...
    1.  
      3
      2
      1

      Hi Patrick,

      Can you attach your form and controller code please?

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

        Hi Bill,

        Thanks for your reply, but I am having trouble importing those packages, we are running on TM 4.3.2.2, is it possible those packages are part of a later version of TM?

        Thanks,

        Pat

        1. Larry Bunton

          Hi Patrick,

          The classes are part of the new Fluent API released in TM 5.0. Your version of TM only supports the older Core API. Create a Groovy Action, here is how to set the ActionResult.

          ActionResult actionResult = new ActionResult(Status.COMPLETED)

          actionResult.setRoute("RouteName")
          return actionResult

           

        2. Patrick McPhan

          Thanks Larry, I've got it all working now

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

        Thanks for your reply Larry.

        I had already tried your first method and it doesn't work for me, I am assuming this is supposed to bind into the RouteName node in the XML? but nothing shows there when I use this method. No matter what I do with this it wants to use the default route.

        The second method looks good however I am having trouble with some of the dependencies. Groovy isn't my strong suit but I have imported a few things to get this script working but am still having trouble. I am getting the error 'unable to resolve' class for the following classes and I cant find what I need to import to get these to work:

        • SvcDef
        • Txn
        • ActionResultBuilder

        Thanks,

        Pat

        1. Unknown User (bfrost)

          Hi,

          You can find ActionResultBuilder in package com.avoka.tm.job.

          You will find the others in package com.avoka.tm.vo.

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

        I don't seem to be able to attach anything here, unless im missing something.

        But if you have access to our maestro projects its the 'Workplace Visit Report Combined' located in the Worksafe project.

        I will paste the controller JSON below:

        {
        "jobDetails": {
        "name": "Workplace Visit Controller",
        "processSubmitImmediate": true,
        "version": "4.3.2"
        },
        "properties": [
        { "name": "Task Form Code", "value": "$func.startFormCode()" }
        ],
        "steps": [
        {
        "name": "Start",
        "type": "start",
        "actions": [
        {
        "name": "Handle Submission",
        "type": "Job Form Start",
        "properties": [
        { "name": "Process Message Text", "value": "Your ${submission.formName} has been submitted" },
        { "name": "Conditional Route Name", "value": "${formDataMap.RouteSelect}" }
        ]
        }
        ],
        "routes": [
        { "name": "Additional", "nextStep": "Deliver One" },
        { "name": "Final", "nextStep": "Deliver Two" }
        ]
        },
        {
        "name": "Deliver One",
        "type": "",
        "actions": [
        {
        "name": "Trigger Submission Delivery Service",
        "type": "Job Delivery",
        "properties": [
        { "name": "Smartforms Delivery", "value": "Smartforms Delivery" }
        ]
        }
        ],
        "routes": [
        { "name": "Default", "nextStep": "Additional visit" }
        ]
        },
        {
        "name": "Additional visit",
        "type": "",
        "actions": [
        {
        "name": "Create Task",
        "type": "Job Task Assign",
        "properties": [
        { "name": "Process Message Send Email", "value": "false" },
        { "name": "Process Message Submission Step", "value": "Start" },
        { "name": "Process Message Text", "value": "Your ${submission.formName} has been submitted" },
        { "name": "Task Assign User", "value": "$func.previousSubmission().userLoginName" },
        { "name": "Task Send Email", "value": "false" },
        { "name": "Task Message", "value": "" },
        { "name": "Task Review Previous Step", "value": "true" },
        { "name": "Task Subject", "value": "Revisit of " },
        { "name": "Task Type", "value": "Review" }
        ]
        },
        {
        "name": "Handle Submission",
        "type": "Job Task Wait",
        "properties": [
        { "name": "Conditional Route Name", "value": "${formDataMap.RouteSelect}" }
        ]
        }
        ],
        "routes": [
        { "name": "Additional", "nextStep": "Deliver One" },
        { "name": "Final", "nextStep": "Deliver Two" }
        ]
        },
        {
        "name": "Deliver Two",
        "type": "",
        "actions": [
        {
        "name": "Trigger Submission Delivery Service",
        "type": "Job Delivery",
        "properties": [
        { "name": "Smartforms Delivery", "value": "Application Deliveryy" }
        ]
        }
        ],
        "routes": [
        { "name": "Default", "nextStep": "Additional visit" }
        ]
        },
        {
        "name": "Application Delivery",
        "type": "",
        "actions": [
        {
        "name": "Application Delivery",
        "type": "Job Delivery"
        },
        {
        "name": "Application Delivery Wait",
        "type": "Job Delivery Wait"
        }
        ],
        "routes": [
        { "name": "Default", "nextStep": "Application Completed" }
        ]
        },
        {
        "name": "Application Completed",
        "type": "endpoint",
        "actions": [
        {
        "name": "Process Message",
        "type": "Job Process Message",
        "properties": [
        { "name": "Process Message Send Email", "value": "false" },
        { "name": "Process Message Submission Step", "value": "completed" },
        { "name": "Process Message Text", "value": "Completed" }
        ]
        }
        ]
        },
        {
        "name": "Application Expired",
        "type": "endpoint"
        }
        ]
        }

          CommentAdd your comment...