Creating Leased Entities
  • 19 Jul 2022
  • 5 Minutes to read
  • Dark

Creating Leased Entities

  • Dark


Data Structure Quick Summary
Complexity?Performance Impact?Saves to Database?Configuration Folder?Entity Framework?Folder Behavior?Process Tracking?
MediumLowYesYes, but not by defaultYesNoNo

Leased Entities are used for batch processing large sets of data and include special properties that allow them to be fetched out of the database and locked. These properties allow multiple threads to operate on the same table simultaneously with no danger of pulling and operating on the same record. Leased Entities are designed for batch processing and then deleted. They are not recommended for the long-term storage of data.

Default Text Length
The default setting for all text stored in the database is 255 characters, however, this can be modified by changing the default Text Length.

Creating a Leased Entities Database Structure

  1. Create a Database Structure [Leased] by clicking Datatypes/Database > User-Defined Types > Database Structure [Leased] on the Folder Actions Panel.
  2. In the Add Leased Data Structure dialog, define the Structure similarly as one would define Database Structure by: naming the Structure, using the Add button to create Fields for the Structure, and finally checking the Enable Actions check-box to create Actions for this Structure.
  3. Select SAVE.
  4. Create a Flow to create Entities of the Lease Data Structure type. In the resulting window, name the Flow and click CREATE to proceed to the Flow Designer.
  5. To create Entities in this Flow, use a CSV file with 1000 records of randomly generated data. In the Flow Designer, add Create Data step from the Favorite Steps category.
  6. Select the Create Data step and click Show Editor under Data to Create, name the Data, and define its type FileData. Select PICK to save and continue.
  7. Define a Constant CSV File for the file Input.
  8. Add a For Each Excel or CSV Row step from All Steps [Catalog] > Data > List > Excel and CSV category.
  9. Select For Each Excel or CSV Row step on the workspace to set it up. 
  10. In the Input Data section, set Input File Type - CSV, Ignore First Row – true, CSV Delimiter – Comma. 
  11. In the Inputs section for File Input, choose Select Value of the file that was defined in Create Data step. 
  12. Connect Done outcome from For Each Excel or CSV Row step to the End Step in the Flow.
  13. On the Next Row outcome from the For Each Excel or CSV Row step, add Create NameLeasedStructure (generated by the System for our Leased Database Structure) from Integrations > My Integrations > User Defined Types > Database Structures [Leased] > NameLeasedStructure category.
  14. Select Show MappingEditor for Create NameLeasedStructure step.
  15. In the Mapping Editor, choose Build Data for Item to Create.
  16. Map the data of Fields.Text Value from the CSV Row to the properties of the NameLeasedStructure object. When finished, save and close Mapping Editor.
  17. In the Flow Designer connect Done outcome from Create NameLeasedStructure step back to For Each Excel or CSV Row step. 
  18. This completes the Flow, save and close the Flow Designer.

Leased Entity Creation Settings

Setting NameDescription

Enable Caching

Enables the Entity to be loaded into the cache

Hide In SearchHides the data type from appearing when being searched

Include ID In Flow Cache KeyAdds the GUID to the Cache Step Key for easier searching

Type Name SpaceCreates the unique identifier for the Entity (namespace.typename) to generate the SQL table name for the Entity (namespace_typename)

Audit ChangesSaves changes to Entity data in the Audited Entities table. This option is used when data monitoring is required for this Entity

Category OrderAllows data field categories to be organized by the Designer

Enable Batch LoadAllows some batch inserting actions to be taken on the back end

Can Be Base TypeAllows the created type to be used as a super-class for sub-classes

Include Type Name In DescriptionThis enables or disables the visibility of the Type namespace

Is Lookup ListSpecifies if the data will be a Lookup List

Enable ActionsAllows actions to be used

Leased Entities in the Workflow Process

Next, this example will demonstrate how to use Leased Entities in the Workflow process.

  1. In the Designer Folder, create another Flow. Name the Flow and click CREATE to proceed to the Flow Designer.
  2. In the Flow Designer add a Go Async [Queue] step from All Steps [Catalog] > Flow Management category. Use this step to run the Flow Asynchronously on the Work Queue.
  3. Add Lease Entity Step from Integrations > All Integrations > Entity Framework > Leasing category.
  4. In the Entity Fetch Definition section select the Leased Entity Structure as Type Name.
  5. Pick a Field to Fetch On and Condition. Note, the field to Fetch on is not recommended to be Entity ID
  6. Next, on Leased Entity outcome from Lease Entity Step, add [Start Linked Flow Async] step from Flows, Rules, Forms, and Reports > Flows category.
  7. Then, on the [Start Linked Flow Async] Step select Pick or Create Flow.
  8. On the resulting window, name the Flow and select Create to proceed to the Flow Designer.
  9. In the Flow Designer, select Start Step on the workspace. Then, an Input of the Leased Entity Structure Type.
  10. Add String Input data to be LeaseID for the Leased Entity.
  11. Add a Save Entities step from Integration > All Integrations > Entity Framework category after Start Step in the Flow.
  12. Select the Save Entities Step and pick the Leased Entity Structure as a Type for Entity Save Definition.
  13. Select Show Mapping Editor for the Save Entities Step. In the Mapping Editor, Build Data for Entity to Save.
  14. Map all fields from Entity Flow Input to Entity to Save except ID. For the ID field, use Text Merge.Plain Mapping Type and click Show Editor.
  15. In the Merge Text Editor, use the Entity ID field along with Flow Data Start Time to modify Entity ID. Click SAVE.
  16. Add Release Lease Step from Integration > All Integrations > Entity Framework > Leasing category.
  17. Map Entity Flow Input Data to entity field, LeasedID Flow Input Data to leasedId field, and set up Constant time For How Long field. 
  18. Add Log (Fast) step from All Steps [Catalog] > Flow Management category.
  19. Select Show Mapping Editor for Log (Fast) step.
  20. In the Mapping Editor, select ConstantWarn level for Log, Ignore all Logs except log01. For log01 we pick Text Merge.Plain Mapping type and click Show Editor.
  21. In the Merge Text Editor, use the Entity’s fields to write to the Log. Select SAVE.
  22. Back in the Flow Designer, connect Done outcome from Log (Fast) step to the End Step. This completes the Linked Flow. 
  23. Save and close the Flow Designer.
  24. Back in the Main Flow on the No Entity to Lease outcome from Lease Entity Step, add the Log (Fast) Step from All Steps [Catalog] > Flow Management category.
  25. Connect the Done outcome from Log (Fast) step to the End Step in the Flow and Show Mapping Editor for Log (Fast) Step.
  26. In the Mapping Editor, pick Constant Warn Log level, Ignore all Logs except log01, and for log01 define Constant String saying that ‘There are No Entities to Lease’. 
  27. Save and close Mapping Editor.
  28. This completes the Main Flow. Save and close Flow Designer.


  1. Select Debug in the top action panel of the Flow Designer. 

For further information on Data Structures, visit the Decisions Forum.

Was this article helpful?