The Modify Task node allows you to make changes to a task located in another process by adding or modifying its parameters. However, you can only modify tasks that are currently in either the Waiting for Callback or Set State nodes (see Picture 1).
Picture 1. Modify Task node task flow
With Modify Task node, you can update a task from outside the process it's currently in, without affecting the workflow of the original process. This can be particularly useful when you need to update specific parameters of a task to reflect new information or conditions.
For example, if a task is currently in a Waiting for Callback node, you could use the Modify Task node to update the parameters associated with the task, allowing it to proceed to the next step of the workflow. Similarly, if a task is in a Set State node, you could use the Modify Task node to adjust the parameters associated with the task, altering its flow within the State Diagram.
Process in which you want to modify the task - The process in which the task will be modified.
Reference of the task you want to modify - The REF of the task you want to modify
Copy all task parameters to the new task - Adds ALL of the parameters of the task that entered the Modify Task node to the task that you are modifying.
Allows you to specify a subset of current task parameters, overwrite them, or add new parameters to be sent.
If you specify a parameter that already exists in the task you are modifying, its value will be overwritten.
Key - parameter name. It should always be a simple string (without quotations). If you’re defining a new parameter, use a name you haven’t used in the task yet.
Value - parameter value. The value you want to assign to this parameter. It can be a constant, a reference to a variable, or a function applied to the above.
Add "key-value" - adds a new parameter field.
Code editor -code editor of the corresponding Key-Value JSON.
Alert if the number of tasks in the node queue reaches the following number - a condition that will be met when the node has a specified number of tasks in it. If this option is selected, a new edge will be created.
Maximum interval, for which the task stays in the node before being forwarded - the amount of time a task must spend in this node. Can be specified in seconds, minutes, hours, or days.
Synchronous callback - if selected, tasks will be updated sequentially - strictly one after another.
The synchronous callback option works if the task you want to modify is in a Waiting for Callback or a Set State node at the moment. Otherwise, the task will not be modified and you'll get the "no_api_callback_in_node_with_task" error.
Modifying a task in a Waiting for Callback node
Let's say we have a task that is currently in a Waiting for Callback node. The task has a parameter called "param" with a value of "I'm waiting", and a reference called "ref1". We want to modify this task by replacing the value of our parameter with the "I'm from modify" value.
To do this, we set up a Modify Task node in another process and specify the process that has the Waiting for Callback node and the task we want to modify. We also add a new parameter to the task with the "I'm from modify" value (see Picture 2).
Picture 2. Using a Modify Task node to replace a task parameter value in a Waiting for Callback node
Once the task has passed through the Modify Task node, it gains a new parameter indicating the status of the modification. In this example, the value is "ok" (see Picture 3).
Picture 3. Example of a task passing through a Modify Task node and getting a new parameter
When the modified task returns to the Waiting for Callback node, its parameter has been changed from "I'm waiting" to "I'm from modify", reflecting the changes requested in the Modify Task node. Additionally, some system parameters are added to the task, allowing us to track where this modification came from.
In this node, you can access a single task parameter or a whole task stored in a State Diagram using these constructions.
Error handling & troubleshooting
When an error occurs in the node, a task goes to the auxiliary Condition output node (Picture 4):
Picture 4. Modify Task node's auxiliary output node
This auxiliary Condition node is used for storing error parameters. With that, the following fields are added to the initial task depending on the error and node type:
|Error parameter name||Parameter description|
|Error type: hardware (system error), software (error in a node logic/settings)|
|Error tag (see the *-marked errors in Error tag column of the table below)|
|Error description in human-readable language. Can be static or dynamic|
|*"not_found_task" error||No task with specified reference exists in the process||Make sure you entered the task reference and process correctly. Note that an empty reference is not considered unique, and even if only a single task with an empty reference exists, you will not be able to access it by reference|
|*"not_found_task" error, even though the task is present in the process||The task might have exited Set State or Waiting for Callback nodes||It might be the case that your task was moved out of those nodes just before it was supposed to be modified. You can either try again or turn on synchronous callback|
|*"access_denied" error||You do not have permission to access the process in which you are trying to modify a task||Typically, the UI will not let you select a process you do not have access to, but you can circumvent that by passing the process ID as a variable. Make sure you have access to the process you are using|
|*"no_api_callback_in_node_with_task" error||The task you are trying to modify is not within a Set State or a Waiting for Callback node||Make sure the task is in the correct type of node.|
|*"duplicate_callback" error||This error can only happen when Synchronous callback was selected. It means that the task is currently being modified.||Corezoid will reattempt the request after 30 seconds.|
*the node errors that are listed with the exact error tag (conveyor_node name_return_type_tag).