Creating, Editing and Deleting Folder Entities with the Flow DesignerLast Updated: 07/20/2016 Introduced in Verision: 2.0
By default, folder entities have pre-configured steps for creating, editing and deleting those entities from within a flow. These steps can be found in the Toolbox tab, under the category Integration > Folder Entity Data Structures > [MyFolderEntity].
In our example, we will create a flow that uses the default folder entity steps to edit, delete and create a new folder entity.
Prior to this example, we have created a folder extension type called “Car.” Within each Car exist a number of CarPassenger folder entities. Each VehiclePassenger has three properties: First name, last name and seat position.
Our new flow will be an action of the Car folder extension and will be called “Add Driver.” When we run this flow, the user will fill out a form containing the new driver’s first name and last name. On submission, our flow will move any car passenger currently in the driver’s seat to the back seat. If the car has four or more car passengers, it will delete the fourth passenger in the car. Finally, our flow will create the new car passenger and place them in the driver’s seat.
Our example also assumes that the Add Driver Form has already been designed.
We will begin creating our flow by navigating to the behavior action folder of our Car folder extension at System > Common Data Elements > Folder Behavior Actions > Transportation.CarFolderBehavior. We will click the Create Flow button.
In the resulting New Flow pop-up, we will name this flow “Add Driver” and click OK to open it in the Flow Designer.
We will begin by retrieving all VehiclePassenger entities from this folder. We will find the Get All VehiclePassenger By Folder Id component in the Flow Designer start-up window, under the category Integrations > All Integrations > Folder Entity Data Structures > VehiclePassenger.
We will map the FolderId flow input to Entity Folder Id and rename the output to “CarPassengers”.
Next, we will place the form with which we’ll add our new car passenger. We will find it in the Toolbox tab, under the category Forms [Interaction] > [Root Folder] > Designer Entities.
Next, we will iterate through each of our car passengers and, if we find one seated in the driver’s seat, move it to the back seat. We will find the ForEach Step component in the Toolbox tab, under the category Flow Management.
Under the Collection section, we will open the Type selector and select a data type of “CarPassengerIntermediate”, then click OK.
After defining the type of the ForEach Step, we must map the source of the CarPassengers through which it will iterate. Under the Inputs > Collection section, we will open the Type selector and select the CarPassengers collection that was outputted from the Get All VehiclePassenger By Folder Id component. Each item outputted by the ForEach Step‘s Next outcome will be called “CarPassenger Item”.
Next, we will test whether the car passenger outputted by the ForEach Step component is in the driver’s seat. We will find the Equals String Case Sensitive component in the Toolbox tab, under the category Data > Text.
For the Equals String Case Sensitive component, we will set caseInsensitive to True and define value2 as “Driver’s Seat”. We will set value1 to CarPassenger Item.SeatPosition.
If a car passenger is seated in the driver’s seat, we would like to move that car passenger to the back seat. We will find the Edit CarPassenger component in the Toolbox tab, under the category Integration > Folder Entity Data Structures > CarPassenger.
In the Mapping Editor, we will first define Seat Position as “Back Seat”.
Next, we will preserve the properties of the CarPassenger we are editing by mapping them directly – with three exceptions.
Because they are generated automatically by the system, we will leave the mapping type of ModifiedDate, ModifiedBy and ExtensionData set to “Ignore”.
If a CarPassenger is not in the driver’s seat, we don’t need to modify it, so we will connect the False outcome from Equals String Case Sensitive 1 back to ForEach Step 1. We will also connect the Edit CarPassenger step’s Done outcome back to ForEach Step 1.
Once we’ve updated the seating positions of our car passengers, we would like to test whether there are four or more car passengers in our Car already, and whether we need to make room for our new driver. We will find the Greater Than Or Equal To component in the Toolbox tab, under the category Data > Numbers.
To compare the number of passengers to our maximum number, we will map value1 to CarPassengers.Count and value2 to “4”.
If there four or more passengers, we would like to delete the last car passenger in our list. We will find the Delete CarPassenger component in the Toolbox tab, under the category Integration > Folder Entity Data Structures > CarPassenger.
To delete the last car passenger in our list, we will map CarPassengers.Last.ID to Id.
Finally, we will create our new car passenger and place them in the driver’s seat. We will find the Create CarPassenger component in the Toolbox tab, under the category Integration > Folder Entity Data Structures > CarPassenger.
When creating a new folder entity, not all properties are required, so we will define only the ones that are. We will map FolderId to our entity’s FolderId property and its EntityFolderID property. The FolderId property is required so the entity knows its destination; this value can never be null (and will not be in this scenario). We will define the Seat Position as “Driver’s Seat” and map FirstName and LastName to the appropriate fields.
For the EntityName property, we will use the Text Merge Plain mapping to combine FirstName and LastName into a single value, then finish by clicking OK and closing the Mapping Editor.
After connecting our remaining flow outcomes, our flow will be complete, so we will save it and close the Flow Designer.
When we navigate to our example Car folder, we will see it contains four CarPassenger entities: Anthony Young in the Driver’s Seat and three others (Daniel Winters, Jenny Abma and Abby Foster) in the back seat.
To add a new driver, we will select the Add Driver action from our Car folder.
In the resulting pop-up form, will give our new driver the first name “Corey” and the last name “Bix”.
On submission, we will see that Corey Bix is now in the driver’s seat. Anthony Young has been moved to the back seat, and our fourth passenger “Abby Foster” has been deleted.