Entity Structure CRUD Actions
  • 14 Aug 2024
  • 3 Minutes to read
  • Dark
    Light

Entity Structure CRUD Actions

  • Dark
    Light

Article summary

Example

Need help creating an Entity Structure?
Please refer to the Creating Entities article for a step-by-step walkthrough.

This example manipulates data within an Entity Structure named 'EntityPerson' with the following data fields:

Data Field NameData Type
FirstNameString
LastNameString
DOBDate time

Entity Data Structures store data in Decisions; however, users will have to create a Folder to store the created Entities. For this example, the Folder 'Entity Person Data' was created. 

Do Not Store Data In The Configuration Folder

Data Structures that are a part of the Decisions Entity Framework will automatically have a Configuration Folder. Do not store data within that Folder. The Configuration Folder is meant for creating Flows, Rules, and other Designer elements to enhance that custom data structure. For more information, please navigate to the Configuration Folder article.

Create

To create a new Entity entry in the Person Entity Data Structure:

  1. Navigate to a Designer Folder. and create a new Flow named 'Entity CRUD Create'. Once created, it will automatically open the Flow Designer.
  2. In the Toolbox, scroll down and navigate to User Defined Types > Entities > EntityPerson. Drag and connect the Create step to the Start and End steps.
  3. Select the Create EntityPerson step to open its the Properties panel. Under Inputs > Folder Id, change the mapping type to Constant to pick the Folder 'Entity Person Data'.
  4. For the Item to Create input, change the input mapping to Build Data which adds input fields matching the Entity Structure's data fields. Navigate to Name, DOB, FirstName, and LastName inputs, set their mapping type to Constant, and provide example data as demonstrated below.

Debug

In the Flow Designer, select Debug from the Top Action Panel. Click the Start Debugger button. The Flow creates a record in the EntityPerson Data Structure with the data provided in the Item To Create's input fields. 

Auto ID Generation
An ID automatically creates when the Flow runs even though the ID input value is set to Ignore.


The new Entity record will now be visible in any Reports using the Entity Structure as a data source.

Update

Entity Structures may use either the Edit or Selective Update steps to change an existing record within the Data Structure. To edit any record in a Data Structure, the Fetch Entities step grabs the specific Entity's ID which then passes into the Edit or Selective Update steps so the change will save correctly.

The Edit step changes every data field in the Entity entry even if only one data field needs updating. Any data fields left without data will be set to Null. When updating, be sure to include information for all fields even for those the step does not intend to update.

On the other hand, the Selective Update step can change the specified data field(s)'s values while preserving the unspecified data field(s)'s values. For most update needs, this step is recommended above the Edit step.

Edit

Similar to the Create Person step, the Edit step uses the Build Data mapping type to populate an Entity's data fields with new information. A notable difference is that this step's ID input defaults to the Select From Flow mapping type to allow the Designer to specify which Entity to update. Select EntityResults.First.ID for this input.

For this example, the Edit step utilizes a Constant mapping type to enter new DOB data while entering the same Name, FirstName, and LastName data to prevent Null values.


After debugging or running the Flow, the Entity updates with the new data field value.

Selective Update 

When using the Selective Update Person step, configure the ID input to the Select From Flow mapping type to select EntityResults.First.ID. With this selected, this step will update the first fetched Entity result from the Fetch Entities step.

Under Data, this example also changes the DOB value. Notice no other data field's inputs must be entered to make this change.


After debugging or running the Flow, the Entity updates with the new data field value.

Delete

The Delete [EntityStructureName] step removes an Entity from the Entity Structure. This step expects an ID input of the Entity to delete which, like the other steps, is mapped from the Fetch Entities step. After providing an Entity ID, running the Flow deletes the specified Entity from the Data Structure.




Was this article helpful?