This topic explains how to use the result of a step in another step, how to change the data type of the step result, and how to declare the return type of the whole job.
There are situations in which you may want to use the step result in an other step. In this case, you will most likely need to change the data type of the step result. Our sample job has an execution step which lists files and directories located on the C drive (Step 1 in screenshot below). When this step returns a result, FlowForce Server automatically assigns the generic type result to the step result. Our goal is to send the directory listing by email.
Since the Message body parameter in the /system/mail/send function is of type string (see Step 4 in Send by Email), we will need to convert result to string. To achieve this goal, we will use the stdout and content functions in one expression, which will allow converting result to stream and then to string (see Expression in Step 2 below). Follow the instructions below.
1.Fill in the function and parameters, as shown in Step 1 (see screenshot below).
2.Declare the result of Step 1 as Step1Output: Type Step1Output in the Assign this step's result to field (circled in red below). You will need to refer to this value later to access the result of the step.
3.Add a new execution step which calls the /system/compute function.
4.Enter the following expression in Parameters: content(stdout(Step1Output)), where Step1Output is the result of Step 1.
5.Declare the result of Step 2 as Step2Output.
Now the job output data type is a string. The next step is to create a new execution step that will send the result of Step 2 by email.
Send by email
To send the directory listing to an email address, take the following steps:
2.The last step is to add a trigger that will fire the job. In our example, we have added a timer trigger that will run the job every 60 minutes (see below) and click Save.
If you want to cache the result of your job, you must declare the return type of the job. Declaring the return type of a job might also be meaningful if you want to use your job as an execution step of other jobs. When you declare the return type, keep in mind the following points:
•Declaring the return type is meaningful only for jobs that actually return a result.
•If you want to cache the result of a job, you must declare the return type.
•The return type of a job must be the same as the data type of the last step in the job. Otherwise, FlowForce Server returns an error. When type-matching errors occur, use expression functions to change the data type of the last step in the job to the data type declared as the job return type. For details, see the example above.
To define the return type of a job, take the following steps:
1.Create a new job or open an existing one for editing.
2.Select a return type in the Execution Result section on the Configuration page.
The available return types are listed below.
•AS2 partner (Advanced Edition)
•AS2 MDN (Advanced Edition)
•SFTP connection (Advanced Edition)
The default option is ignore/discard. It instructs FlowForce Server to ignore or discard the result of the job. Select this option if the job does not return a result or if you do not need to process the returned result in any way.