parent-directory
Extracts the parent directory from a path.
Signature
parent-directory(path:string) -> string |
Parameters
Name | Type | Description |
---|---|---|
path | string | Specifies the path to a directory. |
Examples
Let's assume you have a MapForce mapping which updates a database from an XML file. You have already deployed it to FlowForce Server and created a job from it. Also, you have configured the job run when the content of the directory changes (that is, your job uses a file system trigger, see File System Triggers).
The first step of the job runs the mapping which updates the database:
After the mapping step finishes executing, your goal is to move the source XML file into the subdirectory called "processed". This would help you keep a track of which files have been processed. To achieve this goal, add a new step which calls the /system/filesystem/move function and enter as Source and Target the values shown below:
The parameter value {triggerile} in the Source field instructs FlowForce to move specifically the file which triggered the mapping. The parameter value
{parent-directory(triggerfile)}processed |
in the Target field sets as destination a directory called "processed", inside the current directory. It consists of an expression and of a string. Note that only the expression part is delimited by curly braces (see Embedding Expressions in String Fields). The expression
{parent-directory(triggerfile)} |
calls the parent-directory function and supplies to it the value "triggerfile" as argument.
Therefore, when the job runs, the following actions take place:
1. A script or a user copies a file (let's call it source.xml) into the current working directory (for example, C:\FFSERV).
2. The trigger fires and source.xml becomes the "triggerfile".
3. FlowForce Server executes the step which runs the mapping.
4. FlowForce Server executes the step which moves source.xml to the "processed" subdirectory. Note that the path C:\FFSERV\processed must exist.