1
0
-1

Hi there, I need to define more than 1 conditional route for a step in the workflow.

CanI define 'Conditional Route Name' more than once in that step, or use a big if statement in the Conditional Route Value?

 

e.g.

{ "name": "Conditional Route Name",  "value": "#if ( $formDataMap.routeName == 'Approve' && $formDataMap.requestType == 'CardReplacement' ) Security Task #end" }

{ "name": "Conditional Route Name",  "value": "#if ( $formDataMap.routeName == 'Approve' && $formDataMap.requestType == 'AdditionalAccess' ) Custodian Task #end" }

 

OR

{ "name": "Conditional Route Name",  "value": "#if ( $formDataMap.routeName == 'Approve' && $formDataMap.requestType == 'CardReplacement' ) Security Task

#elseif ( $formDataMap.routeName == 'Approve' && $formDataMap.requestType == 'AdditionalAccess' ) Custodian Task #end" }

 

 

 

 

    CommentAdd your comment...

    3 answers

    1.  
      2
      1
      0

      Hi Dianna,

      The big #if #elseif  (second option) is the one to use.

      Note you can only use 1 "Conditional Route Name" action property in the Task Wait.

      Please refer to the following documentation for contstuction your velociy template

      http://velocity.apache.org/engine/1.7/user-guide.html#if-elseif-else
       

      The velocity templates can be a bit tricky to get right. I usually debug these longer velocity templates using the TM Groovy console. Below is a groovy code example using your velocity template that you can paste into the Groovy console.

      Note I am enclosing the template string in 3 single quotes '''{template}'''. If you use double quotes groovy treats this as a GString an tries to substitute the $formDataMap.

       

      Cheers

      Larry Bunton
      Collaboration Jobs Lead

      Avoka

       

      import com.avoka.core.util.StringTemplate
      import java.util.Map
      Map formDataMap=['requestType': 'CardReplacement',
      'routeName': 'Approve']
      String templateString =
      '''#if ( $formDataMap.routeName == "Approve"
      && $formDataMap.requestType == "CardReplacement" ) Security Task
      #elseif ( $formDataMap.routeName == "Approve"
      && $formDataMap.requestType == "AdditionalAccess" ) Custodian Task
      #else $formDataMap #end'''
      StringTemplate template = new StringTemplate(templateString)
      Map model = ['formDataMap': formDataMap]
      println model
      println template.merge(model)
        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Larry,

         

        Can you please tell me if this is correct

        "steps": [
        {
        "name": "Start",
        "type": "start",
        "actions": [
        {
        "name": "Handle Submission",
        "type": "Job Form Start",
        "properties": [
        { "name": "Process Message Text", "value": "Your ${submission.formName} application is being processed." },
        { "name": "Conditional Route Name", "value": "$func.invoke('Security Access Conditional Route Lookup', ${formDataMap.routeName}, ${formDataMap.requestType}, ${formDataMap.accessGroup}, ${formDataMap.formalLeaderFlg})" }
        ]
        }
        ],
        "routes": [
        { "name": "Formal Leader Task", "nextStep": "Formal Leader Review" },
        { "name": "Primary Custodian Task", "nextStep": "Primary Custodian Review" },
        { "name": "Security Task", "nextStep": "Security Review" }
        ]
        },

         

        It doesn't seem to work.

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

          Thanks for your help. Do you know how I can specify to execute a task if it meets some condition? i.e. outside of the task wait?

           

          I have a Job Controller defined. The first step is Start. Next step is a Manager Review step. I only want this step to be executed if it meets some condition.

            CommentAdd your comment...