Workflow parameters

Middle's parameter system affords you the flexibility to create the automations you need

Whether it be creating booleans in a decision node or inputting data into an action, Middle's parameters are the building blocks of your workflow nodes. When you create a new parameter you will be provided with a large menu of options to select. From there you can select your workflow inputs or past action outputs to supply data. You will compare this data against a variable or static value to generate logic or build switch statements to map what values you'd like to send over to another system. Middle also allows for array manipulation to help you sort out complex records. Workflow parameters allow you to code without being a developer.

Variables

Variables will be the most common parameter you use, as they allow you to reference the record your workflow is working on, outputs from actions, and data embedded in arrays. There are two types of variables: global variables and special variables.

Global variables

When you click on the Global Variable Selector in the parameter menu you will likely be presented with a list that includes the begin node and any previous actions. In addition, you will be able to select a datetime value of Now that can be broken down into date, weekday, day, month, year, hour, minute, and second.

Most likely you will be selecting your input record. So, if your workflow ran every time a sale occurred, you would be selecting the sale record being worked on. You should then be able to see all fields associated with that record. There are a number of different data types and fields you'll find in a record. Most notably you'll see keys. These allow you to connect to and reference records related to the input record. If your workflow is working on a sale record, you can view data about the customer who made the purchase or the products that were purchased.

Special variables

In conjuncture with using array manipulation tools that allow you to work with embedded arrays, you will need to use special variables to access data within these arrays. Once you've accessed that embedded record, the flow behaves similarly to a record accessed via the Global Variable Selector.

Data types

When accessing a record's data via a global or special variable you will see a number of different data types.

PK - Primary ID

This is the primary identifier associated with a record. In the case of a user, this would be their user ID, or in the case of an invoice, this would be the invoice ID internal to the source system.

KEY - Foreign key

When there is a record associated with the record you're currently viewing it will appear as a foreign key. Clicking on a foreign key will link you to that related record.

A string is a text field.

Calculations can be performed on numbers.

Dates can be broken down into year, month, day, and weekday.

Datetimes can be broken down into date, year, month, day, and weekday

Boolean data either has a value of true of false.

A subset of data within in a record, array data can only be accessed by using Middle's array manipulation tools.

{OBJ} - Object

An array of the entire data object.

Flow control

You will use flow control parameters as the nuts and bolts for your logic in Middle.

If

To create a boolean you will need to select If. You now have an If statement with a left and right comparison. You can then compare a number value to a number value, a text value to a text value, a date or datetime to another date or datetime, and a boolean against true or false. With all data types you can check whether or not there is a value present or if the field is null.

Say that you are trying to determine if someone has an active membership. You would first create an If statement, select the field, likely from the input record, that indicates whether or not someone is a member, and then input the value you'd expect to see for an active member in the comparison.

Comparisons

To build a proper IF statement, you'll need a comparison, such as "(Text) is exactly the same as." This comparison is used to power your logic. Depending on the data type, there are different sets of comparisons that can be used in a workflow:

  • Exists and not blank and not zero

  • Does not exist, or is blank, or is zero

  • Exists

  • Does not exist

And

Adding an And to your logic allows you to create a list of If statements. With a list of If statements grouped by an And, all must be true for the logic to pass.

Or

Or parameters group If statements similarly to the And parameter, but instead of all the If statements needing to be true, only one needs to be true for the logic to pass. And and Or parameters can be layered on top of each other or paired with If statements. This allows you to lay out specific criteria for your logic.

Switch

Switch statements are primarily used in Action nodes where logic needs to be performed. Switches allow you to build out “if, then, if else, then, default” logic. Within the Switch you can use If, And, and Or to complete the logic you need to perform. Switches are particularly powerful in mapping and standardizing your data.

As you build out your Switch statement, if you add too many statements, you can pare down your Switch statement by selecting Delete at the bottom of the parameter menu. You can also move parameters between statements by selecting Move Child Back or Move Child Forward in the parameter menu.

Constants and calculated values

Middle allows you to create parameters that are static, calculated, or constructed. These include numbers, text, dates, datetimes, and booleans.

Number

When you create a number parameter you are able to input a static value or you can calculate a value using your variable data. With numbers you can add (+), subtract (-), multiply (*), and divide (/). You can also group your operations together with parentheses. If you need to round your number up or down, group

the value or operation you want in a parentheses and then put "ceil" (to round up) or "floor" (to round down) in-front of the parentheses; IE floor(100.2).

You can also input variables into your numbers. Variables are represented by curly brackets {} as placeholders. The placeholders will then correspond to a list of variables constructed below the number. If you leave your curly brackets blank "{}" they will correspond to the variables in a top-down order. However, if you input numbers into the brackets you can map your placeholders to the brackets.

Text

With text fields you can do anything from creating dynamic text blocks that reference data to converting numbers, dates, or datetimes to strings, so that you can properly push them into another system. Similar to numbers, text parameters in Middle allow you to insert your variable data. Text fields also use the curly bracket placeholder system.

Date and datetime

Any date or datetime you define will be in your timezone.

Manipulating dates and datetimes

Using the Timedelta feature, you can add or subtract from datetimes. To use the Timedelta feature, you will actually want to create a number, input a date or datetime variable and then add or subtract that from an inputted Timedelta. The Timedelta then represents a time value.

You can also subtract or add two dates or datetimes and Middle will output the seconds value.

Boolean

Either true or false, booleans are good for when you want to pass in a static boolean value to another system.

Array manipulation

Arrays are simply a collection of objects. In the context of Middle workflows, arrays are a collection of data objects embedded in a record or action output. A great example of an array is a list of line items in an invoice. This list of line items would appear as an array, along with other fields in the invoice, such as the invoice ID and sale date. When arrays are involved in your data you will need to use array manipulation parameters to parse out the data you need.

If you remember, this is where you will use special variables to reference data within an array.

Count array

The count array manipulation allows you to count the elements in an array. In our invoice line item example, you'd count all the line items in that invoice. When using the count array parameter you will just need to select the array you'd like to count. You can compare the count against a number value.

Reduce array

Say you want to take all of an invoice's line items and derive a dollar value of the items purchased. This is when you'd use a reduce array. Whether you're reducing an array to a number value or text, you can use this manipulation to define a starting value (via the Accumulator Initial value) and then compile array data of your choosing (via the Reducer Operator) to end up with the value you need.

When calculating the Reducer Operator value, Middle will look at each object in the array and pass in the values you've selected. If you create a text or number parameter for the Reducer Operator, you can input a Reduce Special Variable Accumulator and then pair it with the Special Variable you'd like to reduce. The accumulator will keep track of the values grabbed from each object. In the case that you are adding up the price of each line item, the accumulator will keep a tally of the sum total of the line items, as each object is looked at.

In the Special Variable menu you will also see a Special Variable Index. This is number value of the object and its position in the array. For example, line item 1 would have a value of 0, line item 2 would have a value of 1, and so on.

Filter array

Continuing our invoice line item example, say you want to get the value of line items that were only for certain products. You can use a Filter Array manipulation to set some criteria for which objects in an array will be counted or reduced. You will need to select the array you'd like to filter and then you can build the criteria you are filtering by. You will need to use Special Variables to reference the fields in the array objects.

Map array

Sometimes you need to take an array and may it to a new array. This is especially pertinent when pushing data to a bulk endpoint. When you set up a Map Array manipulation you'll have an option of what you want to map this array into. It could be anything from a complete object to pass to another system, to just a list of an individual field.

Deduplicate array

You are able to deduplicate an array when you've mapped an array to an individual field. For example, you could take your list of line items, map it into an array of product IDs, and then deduplicate the list so that you end up with a unique list of product IDs that were in the invoice. The Deduplicate Array tool currently cannot deduplicate across more than one field of data.

Advanced parameters

Construct object

Sometimes in actions you will need to construct objects to send to the destination app. Objects are predefined by the developer in the developer portal and are action-specific. For example, if you are sending data to a CRM, you might need to construct a set of objects that include the field you are updating and the value you are sending over.

Construct array

Actions may require that you construct an array of objects. In this case, you can construct an array and then construct objects in the array. Alternatively, occasionally it can go the other way and the constructed object is a constructed array of data.

Last updated