Logic blocks are comprised of a record in the Logic Block Builder application and the actions which are selected on the Logic Block Builder page of the record. The type of logic block you build determines how it can be used. For example, Transaction logic blocks create, update, and delete records, while Validation logic blocks compare fields within a record or records to validate data. The actions that are available in a logic block are determined by the type selected. Learn more in the Logic block types topic.
Logic block actions are used in different combinations to achieve the logic block's intended purpose. One logic block action could be used to highlight a field if a value exceeds a certain amount, while another could be used to automatically fill in the sequential record number in a sales order field.
Data sources provide records and values for the logic block's actions and expressions to use. Every logic block is built over one, or many, data sources. Data sources can be either entire records or values within a record that can be used as inputs and outputs in the logic block's actions. Expressions are used to narrow down which records or values the logic block actions should apply to. Learn more in the Logic block values topic.
The diagram below shows the interaction between tables, applications, and logic blocks.
| Table—Configured with the fields you want available in the applications and logic blocks which are built over it. Logic blocks and applications can create, update, or delete the records which are stored in the table. | |
| Application—Built over the table. Logic blocks can be attached to the application so that they initiate when certain events occur. For example, you can attach a logic block so that it initiates when a user selects a specific field or row action, or to validate a user entered value when a record is saved. Learn more in the Ways to initiate a logic block topic. | |
| Logic block—Built over the table. Acts as a container for data, values, and variables which are processed and updated as the logic block executes. The data used in the logic block, as well as what actions are performed on the data, are selected during the logic block configuration. For example, you could build a simple logic block to hide a field in the application if a value is entered into a different field. Or, you could use a more complex logic block to fetch records from an outside table in order to insert them into the table your logic block is built over. More complex processes can require multiple logic blocks to function. Learn more in the Logic block actions topic. | |
| Updated Application—Once the logic block has finished executing, any changes made to the application's UI are applied. | |
| Updated Table—Once the logic block has finished executing, any changes made to the table's records are committed. |
Configuration
There are several tools and applications used to create, debug, and test logic blocks. Learn more in the Logic block configuration tools topic.
Logic block foundations: Design, develop, and test
This topic reviews the foundations of logic block design and development. This includes selecting and organizing the logic block actions, determining the scope and required security, and determining how and where the logic block should be initiated.
Design and develop
The following elements should be considered when designing a logic block:
- What does this logic block need to achieve? The type of logic block you build determines the available logic block actions, how the logic block functions, and what it can be used for. Learn more in Logic block types.
- What records and values need to be available for the logic block actions? The logic block inputs and outputs control what records and values can be accessed by the logic block actions. Learn more in Logic block inputs and outputs.
- What type of security does your logic block need? The security option you select for your logic block dictates which permissions are applied to it and how it can be called. Learn more in Logic block security options.
- What objects or values that are created or modified by logic block actions need to be available to other actions? The actions you select, sequence you place them in, and the result of those actions determines the scope of the logic block. The scope references the objects and values which the logic block can see and use as it runs. If an object, value or data source has not been previously fetched or defined, it cannot be referenced in an action. Learn more in Logic block scope.
- How should the logic block be initiated? You can configure logic blocks to initiate based on user interactions, such as a row or field selection, or based on table changes, such as record saves, updates, or deletes. Learn more in Ways to initiate a logic block.
- What is the order of execution for your logic block when table mutations occur? Different configuration options, such as table triggers, logic blocks, auto numbers, and workflow occur in a specific order. Your logic block can be impacted by the other events that occur. Learn more in Sequence of logic block execution on tables.
Example
SCENARIO 1: Application A is used to create different types of receipts. It has fields for Receipt Type, Purchase Order, Item, Receipt Date, Company, and Org Unit.
When a user selects a Receipt Type, you want different fields to be hidden and shown. If a user selects a receipt type of Purchase Order, the Item field should be hidden. If a user selects a receipt type of Item, the Purchase Order field should be hidden. This improves the user experience and helps avoid confusion on what information they need to enter.
To accomplish this with a logic block, you could use the following options:
- Logic block type: You could use an UI or Transaction type logic block. If the logic block is going to perform other operations besides hiding and showing fields, you should use a Transaction logic block type.
- Inputs and Outputs: The logic block must be built over Application A's table.
- Security: The logic block should be included in a security group which users have access to. Likely, the same security group as Application A and its table.
- Scope: N/A
- How to initiate: The logic block should initiate based on a Field Value Changed event action. This means the logic block runs when a user changes a value in a field then exits it.
SCENARIO 2: Application B is a Header Detail application used to create invoices for inventory orders. It has fields for Item, Item Cost, Quantity, and Amount in the Detail application, and fields for Company, Invoice Number, and Order Total in the Header.
When a user enters detail lines for items to include in the order, the cost of an item should automatically populate in the Cost field once a user selects an item in the Item field. Once a user enters a value in the Quantity field, the Amount field should be automatically calculated by multiplying the Quantity x Cost. Once a user exits a detail line, you want the Amount from that detail line to be added to the Header's Order Total field.
To accomplish this, you should build two logic blocks. The first logic block to default the cost, and the second logic block to calculate and update the Amount field, then calculate and update the Order Total field. Use the following options:
- Logic block types: Transaction type logic blocks
- Inputs and Outputs: The logic blocks must be built over the Header Detail table of Application B.
- Security: The logic blocks should be included in a security group which users have access to. Likely, the same security group as Application B and its table.
- Scope: Logic block actions must be completed in a certain order, otherwise the values from previous actions won't be available for calculations. For example:
- Fetch action: Logic block one fetches the Item cost to populate the detail line when an item value is selected.
- Math action: Logic block two multiplies the Cost X Quantity to calculate the Amount for the detail line.
- Math action: Logic block two adds the Amount from each detail line as it is added to the Order Total field.
- How to initiate: The logic blocks should initiate based on a Field Value Changed event action. This means they run when a user changes a value in a field then exits it.
Test
It is essential to test your logic blocks to ensure they fulfill their intended purpose. To test your logic block, you use logic block test harnesses. Test harnesses validate the design of your logic block and monitor for regressions. The development of new logic blocks, or the modification of an existing logic block, is not complete without a test. Learn more in Logic block test harnesses.
Logic block types
Logic block type determines the available logic block actions, how the logic block functions, and what it can be used for. There are several logic block types to select from, such as Transaction, UI, Validation, Background Task, Data Transform, and Test.
| Type | Description | Limits |
|---|---|---|
Modifies data by updating, creating, deleting, or fetching records. Transaction logic blocks:
| There is a limit to how long a transactional logic block can run before the system terminates it, and the logic block errors. | |
| Controls elements of the user interface such as hiding and disabling fields, but does not update any data. UI logic blocks:
| Errors if actions in the logic block insert, update, delete, or fetch. Errors if actions call a logic block that updates or creates records. | |
Compares fields within a record or between records to validate data. This logic block does not update any data. Validation logic blocks:
| Errors if actions call a transactional logic block. | |
Transactional logic block that runs asynchronously, and do not refresh the page when it finishes running. Background Task logic blocks:
| ||
Tests the functionality of another logic block and runs as part of a logic block test harness. Test logic blocks:
| ||
| Used to add or update business data or metadata in a table or change how the value of a field in a specified table is calculated. Uses either a Bulk Update or a Fetch Records action to transform the data.
| Only one Data Transform can be run against a table, but the logic block can have multiple actions. | |
| | Used to build summary tables. They perform a limited set of actions. | Cannot be used to update, insert, or delete records. |
| Used for advanced data mappings in Webhooks. You must configure your mappings using Set Values actions. It should have one JSON Object data item as an input, and a record as the output with the table that the event definition payload is built over as the shape. Once you enter the logic block name, the input and output mappings are automatically populated in the subtables. Add the event payload key in the output mappings where you want to map the payload information. | Cannot be used in other processes. |
Use the questions below to decide what type of logic block to use.
| Does the logic block insert, update or delete records? | YES: Does the user need the results immediately? |
|
|---|---|---|
| NO: Does the logic block fetch records? |
|
Transaction logic blocks
Transaction logic blocks provide a way to change tables by updating, inserting, or deleting records.
In comparison, validation logic blocks fetch records, and then validate without changing the records. In other words, validation logic blocks fetch and verify records, and transaction logic blocks change them.
Validation logic blocks
Validation logic blocks provide a way to create advanced validation of table records. This means that you can use a validation logic block to validate values entered in a record are correct before they are saved. You can also create basic validation on a data item level, for example field formats.
When you create a validation logic block you define the criteria for the specific validations and the fields you are validating. For example, you could use a validation logic block with a bank record application. You could configure the actions to validate values in the Payments Applied field were greater than zero, and that values in the Payment Date field do not occur after today's date.
Validation logic blocks run at different times, including when the user:
- clicks the save button
- changes a field value
- exits a detail row
If the values entered do not match the validation configuration of the logic block, the user sees an error message and their records are not saved.
Background Task logic blocks
Background Task logic blocks provide a way to asynchronously update, insert, or delete records in tables. They are similar to Transaction type logic blocks except they do not have user-dependency on the results.
Regardless of how a logic block is initiated, it executes as a job on the batch server. If the Background Task logic block calls additional logic blocks, the behavior is dependent on what logic block action is used, such as:
- Queue Background Logic Block action—Causes a second process to initiate from the first. The first process continues to run subsequent actions in the calling logic block immediately while the second process is picked up by the batch framework.
- Call a Logic Block action—If the calling logic block is of type Background Task, the processing logic blocks actions are run within the calling logic block's process before the calling logic block resumes. If the calling logic block is a different type, a new job is submitted for the processing logic block and the calling logic block continues to run.
Logic block scope
The scope of a logic block determines what objects and values a logic block can use when it runs. The sequence in which you use actions, and the result of those actions, determines what values and objects are available for the logic block to use as it progresses through the different steps.
Building a logic block
Before you build a logic block, you must consider what actions you need to use, and where they should be placed. The placement of actions can impact what objects or values are available for actions used later in the logic block, for example:
- Variables—Used to set values in your logic block. In order to be referenced by an action, the variable must already be defined in a previous logic block action. If you set a value or a new variable in action 20 of a logic block, you can't use that variable in actions 0 - 19.
- Data sources—Provides values that can be used in the logic block actions. Data sources can be fetched or created. For example, if you use a Fetch Record action to fetch a table lookup on Table A in order to insert it into Table B, the action that fetches that table lookup must be before the action that inserts it. Or, if you use a temp table as a data source, the temp table must have already been created.
If an object, value or data source has not been previously fetched or defined, it cannot be referenced in an action and the logic block errors.
Loops
Some logic block actions, such as fetch actions, use loops. This allows the logic block to loop through retrieved records to apply actions to those records. All of the fetched records are only in scope (available) within the Data Found loop. Actions outside of the Data Found loop can only access the last record from the loop and its values. Alternately, if you use the Call a Logic Block action which does not use a Data Found loop, any values returned from the action are available for later actions.
Running a logic block
When a logic block runs, the scope is determined based on what actions are executed. For example, Conditional actions can compare two values, and then the logic block runs different actions based on whether or not those conditions are met. The actions are divided into a true branch, when the conditions are met, and a false branch, when the conditions are not met. If an action fetches a record in the false branch of a Conditional action, but the conditional is true when the logic block runs, the record cannot be fetched and cannot be used by later actions. If a later action tries to use that fetched record to set a value, the logic block errors since the record is not in scope.
Or, if you use a Fetch Records action and set the value of a new variable in the Data Found loop, and want to set the value of a field outside of the Data Found loop with that variable. If the Fetch Records action does not return any data, the Set Values action in the Data Found loop won't run. The logic block errors because the value of the field cannot be set since the variable was never created.
Naming conventions
Name and format the components of logic blocks consistently to identify different elements in the comments more easily.
Once you establish conventions, maintain them throughout the entire logic block. Think about how those conventions apply to the different elements you use in the logic block.
For example, if you fetch records from the Directory table twice, once to find suppliers and a second time to find customers, you should not name both fetches FetchDirectory. Instead, use FetchSupplierDirectory and FetchCustomerDirectory to make it clear and easy to identify which name to reference later in the logic block.
This includes how you format objects. Formatting refers to how object name is typed out in the comment, such as capitalization, special characters, and spaces.
The table below reviews several conventions used in logic blocks:
| Object | Convention | Example |
|---|---|---|
| Variable names | UpperCamelCase | Create Variable: InvoiceDate |
| Table names | Put the name of the table in parenthesis. | Fetch a table lookup with EmployeeName (Directory) |
| Constants | Format the variable name with UpperCamelCase, and then after the definition put the word constant in parenthesis. | ExchangeRate = 1 (constant) |
Sequence of logic block execution on tables
Logic blocks have a specific table save order of execution when table changes (also known as table mutations), such as record inserts, deletes, and updates occur.
The order of execution for logic blocks is:
- Validation triggers
- Action blocks
- Pre-triggers
- Automatic numbers
- Operations such as insert, update, and delete
- Post-triggers
- Conditional Workflow logic blocks
- Workflow Post Run logic blocks
If the application type is not Header Detail, Workflow executes after post-triggers.
Header Detail tables
If the logic block is built over a Header Detail table, the Header events are run first. After the Header post-trigger is completed, the Detail logic executes in the following order:
- Common fields are populated
- Detail validation triggers
- Detail action block
- Detail pre-trigger
- Detail auto numbers
- Detail operations
- Detail post-triggers
- Header Detail post-trigger
After the records are processed and have gone through each of those steps, Workflow is submitted.
Sequence of logic block processing
This topic reviews the sequence of logic block processing based on the type of logic block being called, the type of logic block that calls it, and how the calling logic block is being run.
Calling logic blocks, also called parent logic blocks, often call multiple other logic blocks throughout the series of actions and logic which it must process. The logic blocks being called, also called processing logic blocks, can then also initiate additional logic blocks.
The type of processing logic block being called, the action that calls it, and how the parent logic block is run determines whether the processing logic block:
- Runs in the same processing event as the parent logic block. This means the parent logic block is interrupted by the processing logic block and does not resume processing until the child logic block and any logic blocks which it initiates completes their own processing event. This is the more common pattern for logic block processing.
- Runs independently of the parent logic block that called it. This means the parent and processing logic block run in separate processing events and do not effect each other.
There are three ways a logic block process can be initiated:
- A Transaction logic block is called from the UI and runs as a UI process.
- A Background Task logic block is called from the UI and runs in the background as a new job.
- A Background Task logic block is called from a scheduled Job and runs in the background as a new job.
The table below reviews how different logic blocks are processed:
| If the parent logic block is a... | And the child logic block is a... | The logic blocks process in the following sequence: |
|---|---|---|
| Transaction logic block | Called Transaction logic block | The parent Transaction logic block is paused, the processing Transaction logic block runs to completion, then the parent Transaction logic block begins processing again. |
| Transaction logic block | Called Background Task logic block Queued Background Task logic block | The parent Transaction logic block continues to run while the processing logic blocks run independently of the parent logic block. |
| Background Task logic block | Called Transaction logic block Called Background Task logic block | The parent Background Task logic block is paused, the processing logic blocks run to completion, then the parent Background Task begins processing again. |
| Background Task logic block | Queued Background Task logic block | The parent Transaction logic block continues to run while the processing logic blocks run independently of the parent logic block. |
Logic block versions
Use the Create Version button in the Logic Builder to create a new version of a logic block. Access and manage versions with the Manage Versions button in the Logic Builder, or the Manage Versions action in the Logic Block Builder application.
Versions are uniquely identified by the Version Name field. When you create a new version, you can also use the Logic Block Version Description field to add notes about why a new version was created, how it is used, or how it is different.
Every logic block version has a ParentID, which connects the version with the logic block it was created from. This value is created automatically and does not display.
Versions of a logic block are different than branches of a logic block. Logic block versions are historical, and only the active version can be edited. You can compare version to each other and restore older versions if necessary. Branches are used for concurrent development. The system automatically creates versions when you merge changes to your branch of a logic block that you can revert to. A version is also automatically created when changes are made to a base logic block that has outstanding branches, so that you can review the changes before merging your changes. Learn more in the Branch and merge topic.
Versions can be accessed and managed with the:
- Logic Builder—Select the Manage Versions button to open a list of versions. From this list you can create, view, or delete versions. When you view a version you can see the logic block actions, and the details of a selected action. To revert to an older version, view the version you want to apply and select the Apply Version button. You must save your logic block to apply this change.
- Logic Block Builder application—Select the Manage Versions row action to open a mini app that displays the list of logic block versions. From the Versions mini app you can use the Apply Version row action to restore a previous version, or to delete a version.
Logic Block Builder application
Application developers use the Logic Block Builder application to create, alter, and build logic blocks.
Use the Logic Block Builder to build expressions for tables, applications, application records, and other Nextworld objects. Each logic block is configured with a sequence of actions that interact with and change the objects they are built over. For example, there are logic block actions that can:
- Apply logic based on the conditions you define.
- Apply styles to fields.
- Perform complex math.
- Set values in a field.
- Call other logic blocks.
Learn more in Logic block actions.
General Configuration
Define the type of logic block, security options, and data sources. By default, logic blocks are built over a single table but you can select the Advanced Input/Output field action to define multiple data items and records as data sources for your logic block.
Logic Block Builder
Define the sequence of your logic block in the Logic Block Builder. The Logic Block Builder is accessible as a page in the logic block record, or from the form action.
The Logic Block Builder contains three sections in which you can configure and build your logic block. The three sections are the:
- Actions panel—The list of all available actions for your logic block type.
- Logic Block panel—The sequence of logic block actions you select and define.
- Properties panel—The configuration options for the action selected.
See the Logic Block Builder section for more information on building logic blocks.
Logic Block Validations application
Application developers use the Logic Block Validations application to validate all the logic blocks owned by your current tenant.
To validate, select the Validate Logic Blocks form action within the application. This initiates a background task which refreshes the list form, validates your owned logic blocks, and then notifies you upon completion.
Records are created for any failed validations found in your logic blocks. Open a record to review the error message, and the number of the action which failed validation.
Asset Usage Inquiry application
Application developers use the Asset Usage Inquiry application to keep a record of the Nextworld objects that are consumed, or used, by logic blocks.
Use this application when you want to filter for a Nextworld object to see which logic blocks consume it or are consumed by it. For example, you can use the Asset Usage Inquiry application to filter for a specific table to see all the logic blocks it is used in, or you can filter for a specific logic block to see all the tables that are used in it.
When you save or generate a logic block in the Logic Block Builder application, records are automatically created and saved in the Asset Usage Inquiry application. The Asset Usage Inquiry records contain data on the logic block that allows a user to filter for logic blocks and the objects that use them or are used by them. Each record in Asset Usage Inquiry lists the consumer asset, which is always a logic block, and the asset being consumed, the object being used in the logic block. The object being consumed by the logic block can be a:
- Data Item
- Table
- Logic Action
- Logic Block
The records in Asset Usage Inquiry are updated any time the logic block is updated in Logic Blocks.
For example, if you searched for the SalesOrderDetail data item in the AssetUsageConsumed field filter to see which logic blocks use it, this is how a few of the records would appear in Asset Usage Inquiry:
| AssetUsageConsumerType | AssetUsageConsumer | AssetUsageConsumedType | AssetUsageConsumed | Table Name |
|---|---|---|---|---|
| Logic Block | AddToOnHandQty | Data Item | SalesOrderDetail | ShipmentDetail |
| Logic Block | ConvertQuoteToSO | Table | SalesOrderDetail | |
| Logic Block | HideShowItemLedgerTransactionsFields | Data Item | SalesOrderDetail | ItemLedgerTransactions |
If you searched for the HideShowAgreementsField logic block in the AssetUsageConsumer field filter to see if any data items, tables, or logic action definitions are in it, this is how a few of the records would appear in Asset Usage Inquiry:
| AssetUsageConsumerType | AssetUsageConsumer | LogicBlockAssetUsageConsumedType | LogicBlockAssetUsageConsumed | Table Name |
|---|---|---|---|---|
| Logic Block | HideShowAgreementsField | Table | AgreementDetail | |
| Logic Block | HideShowAgreementsField | Data Item | CompanyCurrency | AgreementHeader |
| Logic Block | HideShowAgreementsField | Logic Action | Comment |