Use a parameter in an action

Hi,

Could an example of using a manual workflow parameter be shared here please.

I’ve been trying to follow the details found Here but can’t quite get the syntax correct, for creating the parameter.

Use a parameter in an action
Add an action via the /api/workflow/{code}/action endpoint (Swagger/ReDoc).
For the parameters property, specify an array containing at least one object with a discriminator of WorkflowComputedItemAttributeWebModel.
For the value property of the WorkflowComputedItemAttributeWebModel object, specify an object with a discriminator of WorkflowSyntaxNodeTriggerParameterWebModel.
For the parameterCode property of the WorkflowSyntaxNodeTriggerParameterWebModel object, specify the relevant attributeCode from your parameter design.

Hello Howard,

Here’s a simple example that’s hopefully going to help you.

Consider we have previously created a design designs_myMWFdesign_64918c43fb74b276cc235b40 that implements designInterfaces_workflowManualTrigger and has a string attribute named attributes_myMWFdesignMyString_64918cc3fb74b276cc237555

Additionally consider that we have created a workflow that in its trigger we have specified
"parametersDesignCode": "designs_myMWFdesign_64918c43fb74b276cc235b40"

This is an example of using the endpoint
/api/workflow/{code}/action
if we wanted to add an action to our workflow, that takes a designInterfaces_tasks as an input, and edits its description with a trigger parameter.

{
  "ancestorId": "64c0e3203816587cc8b88928",
  "signature": "64c0e5283816587cc8b92d71",
  "description": "Editing Action",
  "parameters": [
    {
      "discriminator": "WorkflowComputedItemAttributeWebModel",
      "attributeCode": "attributes_tasksDescription",
      "value": 
        {
          "discriminator": "WorkflowSyntaxNodeTriggerParameterWebModel",
          "parameterCode": "attributes_myMWFdesignMyString_64918cc3fb74b276cc237555"
        }
    }
  ],
  "actionDesignCode": "designs_workflowEditItemAction"
}

Then when triggering the manual run, we specify our string for that attributes_myMWFdesignMyString_64918cc3fb74b276cc237555 attribute

{
  "query": {
    "type": "Query",
    // Some query that returns one or more tasks
  },
  "triggerParameters": [
    {
      "attributeCode": "attributes_myMWFdesignMyString_64918cc3fb74b276cc237555",
      "value": "It's a tough job, but someone's got to do it"
    }
  ]
}

Hope this helps, but please let us know if you have further questions.

Best regards,
Niko

That’s great, Is it possible to use the parameter in a filter node?

Yes, trigger parameters can be used in all types of nodes just like any other type of parameter, provided of course that a value is passed in the manual run that matches the trigger parameter attribute (like the example above)

could you please provide an example of use within a filter.

Yes, similarly with the edit node example:

Consider we have previously created a design designs_myMWFdesign_64918c43fb74b276cc235b40 that implements designInterfaces_workflowManualTrigger and has an AQS attribute named attributes_myMWFdesignMyAQS_64c11c193816587cc8c8f6ee

Additionally consider that we have created a workflow that in its trigger we have specified
"parametersDesignCode": "designs_myMWFdesign_64918c43fb74b276cc235b40"

This is an example of using the endpoint
/api/workflow/{code}/action
if we wanted to add a filter action to our workflow, that takes a designInterfaces_tasks as an input, and determines whether the execution will continue, by evaluating an AQS query that we’ll provide later as a trigger parameter.

{
  "ancestorId": "64c0e3203816587cc8b88928",
  "signature": "64c0e5283816587cc8b92d71",
  "description": "Filter node",
  "parameters": [
    {
      "discriminator": "WorkflowComputedItemAttributeWebModel",
      "attributeCode": "attributes_workflowFilterActionsAqsQuery",
      "value": 
        {
          "discriminator": "WorkflowSyntaxNodeTriggerParameterWebModel",
          "parameterCode": "attributes_myMWFdesignMyAQS_64c11c193816587cc8c8f6ee"
        }
    }
  ],
  "actionDesignCode": "designs_workflowFilterAction"
}

Then when triggering the manual run, we specify our AQS for that attributes_myMWFdesignMyAQS_64c11c193816587cc8c8f6ee attribute

{
  "query": {
    "type": "Query",
    "properties": {
      "collectionCode": "Live",
      "dodiCode": "designInterfaces_tasks"
    }
  },
  "triggerParameters": [
    {
      "attributeCode": "attributes_myMWFdesignMyAQS_64c11c193816587cc8c8f6ee",
      "value": {
        "type": "Query",
        "properties": {
          "attributes": [
            "attributes_itemsTitle",
            "attributes_itemsSubtitle"
          ],
          "collectionCode": "Live",
          "dodiCode": "designInterfaces_tasks"
        },
        "children": [
          {
            "type": "Equals",
            "children": [
              {
                "type": "ItemProperty",
                "properties": {
                  "itemPropertyName": "itemId"
                }
              },
              {
                "type": "AlloyId",
                "properties": {
                  "value": [
                    "6196652072d6600157287ef3"
                  ]
                }
              }
            ]
          }
        ]
      }
    }
  ]
}

In the above example we are running this workflow for all the tasks in the customer, but the execution of the next nodes will only continue for the task with
itemId: 6196652072d6600157287ef3

Thank you. That does answer my question. Although the functionally of the trigger parameters is not what I expected.

I wasn’t expecting that the parameter from the trigger would be an AQS query.
I was hoping I could use a string, datatime, number etc. trigger parameter and use that directly in the filter, like other parameters.

e.g.

{
  "type": "Query",
  "properties": {
    "collectionCode": "Live",
    "dodiCode": "designInterfaces_tasks",
    "parameters": [
      {
        "name": "Param",
        "type": "DateTime",
        "title": "Param"
      }
    ]
  },
  "children": [
    {
      "type": "GreaterThan",
      "children": [
        {
          "type": "Attribute",
          "properties": {
            "attributeCode": "attributes_tasksRaisedTime"
          }
        },
        {
          "type": "DateTime",
          "properties": {
            "parameterName": "Param"
          }
        }
      ]
    }
  ]
}

Yes that would be possible as well, through the use of variables that can be interpreted as AQS parameters. Using your example above, our AddAction request would look like this:

{
  "ancestorId": "64c11a053816587cc8c88859",
  "signature": "64c78d376e77cbecc80cce21",
  "description": "Filter node",
  "parameters": [
    {
      "discriminator": "WorkflowConstantItemAttributeWebModel",
      "attribute": {
        "attributeCode": "attributes_workflowFilterActionsAqsQuery",
        "value": {
          "type": "Query",
          "properties": {
            "collectionCode": "Live",
            "dodiCode": "designInterfaces_tasks",
            "parameters": [
              {
                "name": "Param",
                "type": "DateTime",
                "title": "Param"
              }
            ]
          },
          "children": [
            {
              "type": "GreaterThan",
              "children": [
                {
                  "type": "Attribute",
                  "properties": {
                    "attributeCode": "attributes_tasksRaisedTime"
                  }
                },
                {
                  "type": "DateTime",
                  "properties": {
                    "parameterName": "Param"
                  }
                }
              ]
            }
          ]
        }
      }
    }
  ],
  "variables": [
    {
      "name": "Param",
      "value": 
        {
          "discriminator": "WorkflowSyntaxNodeTriggerParameterWebModel",
          "parameterCode": "attributes_myMWFdesignMyDateTime_64c78afc6e77cbecc80c1da1"
        }
    }
  ],
  "actionDesignCode": "designs_workflowFilterAction"
}

…Considering again that our design designs_myMWFdesign_64918c43fb74b276cc235b40 implements designInterfaces_workflowManualTrigger and has a DateTime attribute named attributes_myMWFdesignMyDateTime_64c78afc6e77cbecc80c1da1

1 Like