Load Variable from Project Output
Last Updated on by
Load Variable from Project Output is a procedure action with a variety of potential uses, as the following examples illustrate:
- Pass XML data to a project to transform into some other XML format.
- Given an order ID, look up the order details from a database, returning the order information in XML format.
- Given an error code, call a subproject to convert it into an error message. This encapsulates the details of obtaining the error message into that one project.
To add this action to an existing procedure, right-click on the Procedure, select “Add Action”, then select “Load Variable from Project Output…”
1) From the Project field, select the project to call.
2) Select the type of input, from a component or from the procedure variable.
3) Set the Input format appropriately for the input data. If it is XML, the Character set will typically be UTF-8.
4) Add any parameters to be passed to the project. See the Calling Sub-Projects article for more information about passing parameters and accessing those parameters in the subproject. Set the Output format for the type of data the sub-project will return.
On the other hand, if the sub-project will return plain text, set the Output format to Text and the Character set to an appropriate value for the data being returned, perhaps ISO-8859-1. Regardless of the type of data the sub-project returns, place the data into a variable to be able to use it later in the project, by placing a “Set Variable” action immediately after the “Load from Project Output” action:
In this example, the XML returned by the sub-project is now stored in the variable XMLPackslip. If the sub-project returns a single text value, you may need to do a Left Trim and a Right Trim to remove any leading and trailing carriage return and/or new line characters. Here is an example:
After this call, we set the value into the variable FolderID:
But the FolderID variable starts and ends with a CR/LF (carriage return/line feed), represented by \r\n.
We can apply a Right Trim and a Left Trim function to the variable, either in the definition or in the procedure, before setting the value returned from the sub-project into the FolderID variable.
We can see that the value of FolderID no longer has the leading and trailing \r\n:
In summary, the Load Variable from Output action can be useful for calling a sub-project that will return data to be used in further processing.