Creating Triggers from a Subtree
This article is going to look into an example of creating Update triggers from within a subtree (in Task 3). To complete a subtree, the "Return" type of node is generally used. This node is a Complete trigger that prompts for the inputs for the variables to be returned from the subtree. This means there is generally no need to create a trigger within a subtree. But what about the case where you want to report back some kind of update to the main tree? That would require an update trigger from the subtree.
So, here we have the beginning of a tree. The first node takes in a value and does something. This could be creating an incident or an asset or a work order or anything. In this basic sample, it takes in an integer and does some math. Then, we want to send an update. This could be a status update from the incident (would be an update connector) the incident number (would be a create connector) or the fact that a certain step is complete (complete connector). It depends what your needs are. In this sample, once the math is complete, we want to send our new number to the main tree.
To do that, we use the "Create Trigger" handler and select the "Update" action:
Then, for the deferral token, we want to select the Source Id:
And we select our desired value for the update as the message. Leaving our node looking like this:
Now, this update (on complete) will only fire once. An update trigger on update (such as on status change of an incident) could fire repeatedly. Sometimes this is important to note: that updates can sometimes occur more than once. You will not want to do anything in your main tree that is only possible once (like record closure) on an update trigger that will happen more than once.
For information on how to access the message from an update trigger, in the node in the main tree, reference