0

Functions

  • updated 2 yrs ago

Description

A function is callable logicnet with a defined interface of inputs and outputs. The function logicnet can be called multiple times within an application, each time using different values for the input and output parameters required. Functions support the sharing and repeating of common logic, which makes the design task quicker and more efficient. You can use functions in conjunction with the library concept to offer reusable library modules to share between multiple projects.

Use

To set up a function you create a logicnet that breaks out into steps a repeating set of logic processes, and then you specify the input and output labels and fields of that function. To access the function from another logicnet you use a call node to invoke the function logicnet. The call node part editor displays the input fields for the function in a Parameters tab (only visible for functions), and can be populated with values (or variables from the context) relevant to that step in the logic flow. During runtime, the system uses the parameters in the function logic and populates the output with the results. The active pathway returns to the original logicnet with the output variables saved to the context for use by downstream processes.

Functions can run in their own context (meaning the variables are held in a system-generated context not accessible by or confused with the rest of the application) to avoid interference with the global context where the application data object values are stored. When sharing functions across applications and libraries, running in private context insures the independence of the function variables. If the function needs access to other variables within the global context, it should be run with private context unchecked.

In either case, the temporary data structures created are cleaned up as part of the function and are not visible or referenced in the context after exiting the function.

Editor Fields

Field Name Description/Use Type/Options Optional/Mandatory
Description This is where you enter a description for the function. It is displayed in the Parameters tab of the function's call node. Text Optional
Cachable This feature is under development. Checkbox Optional
Private Context By selecting this checkbox you tell the system to run the function in a private context if the function is being shared across applications/libraries to avoid any risk of interaction with other data models.

If you leave the checkbox empty, the system runs the function in the public context if the function needs access to other variables in the global context.
Checkbox Optional
Caption This is the label that will appear in the Parameters tab for this input or output. Text Optional
Data Object Name This should reference an object in the function logicnet itself. Text Mandatory
Type Enter the type of information to be entered into this parameter. Use "variable" if the parameter is a data object generated in the context. Use "text" if the parameter needs to be a hard-coded string, number, or text. The function will adhere strictly to this definition; for example, if this is set to "variable" and the user enters "5", the system will not continue. text | variable (lowercase only) Mandatory
Data Type This is where you specify the exact nature of the parameter (when Type = variable), otherwise choose text. Data type can be chosen from the picklist or manually typed, lower case only.

Note that data type can also be a datamodel (advanced feature)
text | number | datetime | date | time | collection | container | options | dm (datamodel_name) Mandatory
Input/Output Specify whether this parameter is used as an input or an output parameter. Input | Output Mandatory

Screenshots

The details below include screenshots and descriptions relating to a simple function that adds together two numeric variables: in this case, it adds the the age of grandparents. You can download this example as a zip file that you can import into your Designer workspace.

How to Create and Use a Function

Step 1 - Design the Repeating Functionality in its own Logicnet

Sometimes you realize that a set of logic flows needs to be repeated only after you have designed the flow. In this case, copy and paste the nodes into a new logicnet and give it a relevant name, storing the logicnet in a Functions folder if appropriate.

Otherwise, you can design any function by building the steps directly in a logicnet. For the input variables use __in. as a container in front of the object name, and use __out. as the container for the output(s). For a logicnet that has already been modelled, just edit the object names to include these containers.

Look at the Datamodel tab in the Designer for your function; it should look similar to the example below.

Step 2 - Convert the Logicnet into a Function

Select the logicnet from the Project menu and click Modify on the Details tab. The I/O Parameters table is at the bottom of the screen. Enter the input and outputs for the function here, excluding the __in. and __out. containers. Give each variable a label that is easy to understand (for example, it is helpful to include whether it is an input or output), and complete the table according to the parameter definitions (see Parameters section above). Once completed, the Parameters table should look like the example below:

Step 3 - Call the Function in the Application Logicnet

At the appropriate point(s) in the application logicnet, the function can be inserted by placing a regular call node into the pathway, and specifying the function as the logicnet to call. When a function is called, the call node part editor displays a Parameters tab showing input boxes for the inputs and outputs used by the function. These should be filled in according to the definitions of the function. If a variable is required, enter container.object_name (no $() construction required).

This step can be repeated as many times as required, each time with different parameters.

In the example, the result of the function is shown in this DATA extract. The steps the logicnet engine took were to:

  • use the input variables of grandfather_age and grandmother_age as the age1 and age2 inputs
  • run the function logicnet (and add the ages together and write the outcome in the result)
  • put the result into the output variable in the context (grandparent_age)


Note that the function variables __in.age1, __in.age2 and __out.result are not shown in the context as the LogicNets engine cleans up the temporary function variables.

Tips and Tricks

Provide detail in the parameter labels (include input or output, and what type of data is expected - text, variable, number) - this is helpful for Designer Users who didn't build the function.

Build and test the function outside of your application first, to work out any defects.

Include function or fn in the logicnet name, or in the call node label so it is easier to distinguish between regular call nodes and function calls.

For broader functions where an input could be either a variable name or text/numeric, build it as text and write rules in the function to verify whether the input is a variable in the context (and use that value) or not (and use the raw input). Or include two inputs (one as a variable, one as text) and build a check in the function to verify which field has been populated.

Advanced Features

Logicnet functions can utilize a wide range of the basic building blocks in the LogicNets Designer. This includes using rules (for example to verify if certain Parameter fields have entries, and take alternative paths based on those inputs - this is useful in building multifaceted functions that need to complete a data process but also handle variations). This also includes calling other logicnets as part of the function (which is useful in keeping logicnet building blocks small and manageable)

Parameters can be of type = datamodel. This is very useful in moving large sets of data corresponding to a datamodel through a process.

Examples

Download and import the example functions into your Designer.

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 2 yrs agoLast active
  • 62Views
  • 3 Following

Home