List Input Attributes
Last updated
Last updated
Nected now supports a new List data type, enhancing the ability to define versatile input parameters for your rules. This addition allows you to incorporate lists of values as input attributes, enabling dynamic rule configurations.
Add Input Attributes: Click on the "Add Input Attributes" button, and “1. Input Attributes” will be shown.
Create New Field: Click on “+Add Field,” enter a Name for the attribute, and select "List" as the Data Type from the dropdown menu.
Configure List Parameters: After selecting List as the Data Type, the List Editor will appear. If it is not visible, it can be accessed by clicking on the List Editor button.
The List Editor provides two modes for adding input data:
Raw Mode: This mode allows you to input raw JSON data for the list directly. It provides precise control over the list structure.
Pretty Mode: This mode offers a user-friendly interface, formatting the list data for easier readability and editing.
Inside the List editor, you can add various data types to the list items, including:
String: For alphanumeric data, such as names or addresses.
Numeric: For numbers, including integers and decimals.
Date: For date values without a time component, in the format YYYY/MM/DD (e.g., 2024/07/16).
DateTime: For date and time values, in the RFC3339 format (e.g., 2024-07-26T00:00:00+05:30).
Boolean: For true/false values.
JSON: To input raw JSON data.
List: To input a nested list of items, which could be numbers, JSON objects, or any other type.
After adding the inputs, you can test them using the Test button. This allows you to validate the LIST structure and data types.
Save your inputs once you are satisfied with the data by clicking the Save button at the bottom of the editor.
Once you have configured your List, save your input attributes by clicking 'Save and Next' button and then comeback to the rule editor window.
Utilize the List in Rules: Now the list attributes can be used to set up conditions in your rules. To do so, go to the Rule Editor and from the property dropdown to select the list attribute you just created. Now in the property you can choose between the first item of the list or the entire list as the property.
Using the Entire List: If you need to apply a condition based on all items in the list, select "Complete List" from the options. This allows you to set conditions that consider the entirety of the list. For example, you might use the "equals" operator to check if the list matches another list or specific values you input manually.
For the entire list, you can either add manual values or can give another entire list as value as you've done in the time of configuring the list attribute. In case of adding a list(maybe another or the same list) you just need to select the list token from the dropdown and that's it. By hovering on the list name, you can see the list items as shown in the image.
Using First Item: To focus on the first item of the list, use the token list_attr[0]
to target the first item of the list list_attr
. This selection is particularly useful for rules that apply only under certain conditions based on specific list items.
Test Your Rule: After succesfully adding the in conditions, execute the rule by clicking on the “Test Now” button.
Review Output:
The output will demonstrate how the rule processed the input based on the conditions set.
This iterative testing process helps confirm the rule’s effectiveness and adaptability across different scenarios.
For List attributes, along with the generic operators, there are special List operators as well.
By following these steps, you can efficiently define custom input attributes using the List data type in Nected, focusing more on refining the logic and conditions of your rules without manual data entry.
Now, let’s see how list attributes interact with common/generic operators and list-specific operators.
1.Any: Checks if any element in the list meets a condition.
Example: any(x > 3 for x in [1, 2, 3, 4, 5])
returns True
because there are elements greater than 3.
2.Exists: Not a direct Python operator, but conceptually, checking if the list exists (is not None
).
Example: exists = [1, 2, 3, 4, 5] is not None
returns True
, indicating the list exists.
3.Does Not Exist: The inverse of Exists; checks if the list does not exist.
Example: does_not_exist = not [1, 2, 3, 4, 5]
returns False
, as the list exists.
4.Is Null: Typically applies to individual elements or objects; for lists, checks if the list is None
.
Example: is_null = [1, 2, 3, 4, 5] is None
returns False
.
5.Not Null: Checks if the list is not None
.
Example: not_null = [1, 2, 3, 4, 5] is not None
returns True
.
1.Empty: Checks if the list is empty.
Example: empty = not [1, 2, 3, 4, 5]
returns False
, indicating the list is not empty.
2.Not Empty: Checks if the list is not empty.
Example: not_empty = bool([1, 2, 3, 4, 5])
returns True
.
3.In: Checks if an element is in the list.
Example: 3 in [1, 2, 3, 4, 5]
returns True
.
4.Not In: Checks if an element is not in the list.
Example: 6 not in [1, 2, 3, 4, 5]
returns True
.
5.Contains: Similar to "In"; checks if the list contains a specific element.
Example: Same as "In".
6.Not Contains: Similar to "Not In"; ensures the element is not in the list.
Example: Same as "Not In".
7.MatchAll: Custom logic, not a built-in Python feature. Conceptually, checks if all elements match a condition.
Example: all(x < 6 for x in [1, 2, 3, 4, 5])
returns True
.
8.Not MatchAll: Inverse of MatchAll; checks if not all elements meet a condition.
Example: not all(x < 4 for x in [1, 2, 3, 4, 5])
returns True
, as not all elements are less than 4.
9.Equals: Checks if the list equals another list.
Example: [1, 2, 3, 4, 5] == [1, 2, 3, 4, 5]
returns True
.
10.Not Equals: Checks if the list does not equal another list.
Example: [1, 2, 3, 4, 5] != [6, 7, 8, 9, 10]
returns True
.
By following these steps, users can effectively manage and utilize list attributes in Nected to enhance their data processing and rule-based logic applications, making the most of the platform's capabilities for dynamic data interaction.