Advanced Links

You can also utilize more advanced expressions. To create these links, select your Field Definition and then go to the Drilldown Menu (the Hamburger icon) and select Advanced. From here, you can add ( + ) advance expressions utilizing Advanced Link entry box, or the Link DbfScript entry box. You will specify this on the field in the form that will show the dropdown list. 

 

Link DbfScript 

The simplest way to create advanced links is to use the Link DbfScript box. This can be any DbfScript expression, but evaluates to a path. For example, you could enter &root/Users[IsAdmin=True] in the box to link to the list of users that are administrators. You can also invoke functions such as ClearPredicates(&path), or reference other fields through #input, such as &root/Users[Department=#input/Department]. These functions must return a path.

While the Link DbfScript must be a simple expression, you can also invoke your own scripts defined in Script Libraries by using the RunPlugin function. Other than a path, a DbfScript Link expression can also return a list of records instead of a path, and the values of the list will be displayed in the dropdown, the path of each record in the list being used as the link. The record added to the list should have a title field defined. Typically such functionality would be put into a plugin script and invoked using "RunPlugin(...)", so you have more space to implement the lookup logic. You can use all of the fields in the immediate form using #input, or fields in a parent form (edited on the same page) using #form.

Note: There will be no paging when this list is displayed - all results will be displayed on one page, so be careful not to have it return too many items. Any predicates that are used can also reference sub-records. 

For example, to find a list of users that have the manager role you can use a DbfScript Link expression like this: 

&root/Users[Roles/RoleID="Manager"] This will filter the users list by all users that have a Role record with the RoleID of Manager. 

Advanced Link 

An alternative is to use the Advanced Link box. Here, you need to enter a special notation known as an XPath. You'll need to be a little familiar with the your data model in order to use this field. An XPath is like an address to a part of the data model. XPaths are similar to how we might refer to paths in Microsoft Windows or filing systems in other platforms. Basically, it's a list of type names. Each type name refers to the name of the field definition that you have created, and each is separated by a forward slash, /, character. For example, a basic XPath might look like this: 

/Products/News 

Often, the first item in the path is a forward slash, which indicates it starts at the top-level of the data model. However this first item in the path list can also indicate that we're starting from somewhere else in the data model. If the path starts with double dots, it indicates that the path starts from the parent type of the current type. For example, in a more complex data model for a task manager, you might want Task Assignment to be selected from the list of Team Members of the Team. The Team is the parent type of the task, so for the 'Task Assignment' we might have a foreign link such as this: 

../Members 

You can also specify another foreign link field in the current record to act as the root of your path. To do this you start the path with a row function. For example:

$row(CurrentProject)/Task 

This indicates that the CurrentProject field in the record will be used to start the path, and the Task drilldown from the selected project will be used as the selection list.

It doesn't have to refer to a field name in the current record either. You can also specify the field of another parent record in the current path. If you know the name of the type of that record, you can put something like:

$row(*/Company/President)/Posts 

This will get the Company record from the parent records, then read the link in the President field (which might point to a User record), then finally get a list of all the Posts made under that user record. The start of the path can also indicate a type name to find. The type name to find uses its fully-qualified name, which means that it is prefixed with all of the types that come before it. For example, if I had a type called Task under a type called Project, then the fully qualified name of the Task would be the ProjectTask. In the previous example, rather than starting with ../Members, we could be more explicit and indicate the actual type we want to find based on the current location. To do this, we start with an asterisk, followed by the fully qualified type name, and then the fields we want to traverse from that location. For example: 

*/Team/Members 

Finally, you can also specify filters to apply to the list. You do this by specifying the filter (also known as a predicate ) in square-brackets [ ]. The filter must refer to a field in the type that is specified by that part of the path. Each filter predicate is specified as a field name, a comparison operator, and a value. For example, if we wanted to only show the team members that were available for assignment, we might have a foreign link such as this: 

*/Team/Members[Available=True] 

This will then show a list of members for the team that have their available field set to Yes (which is indicated as True in predicates). You can use these symbols: equals =, not equals !=, greater than >, less than <, greater than or equals to >= ,or less than or equals to <=

Note : Complex filter values, such as formula, are not currently supported. Instead you can create a separate formula field and reference that in the filter. For a more in-depth look at paths, consider reading the DbfScript Reference on understanding paths.


Next Topic:
v4.2.0.956 (beta)
Up Since 2/29/2024 12:02:23 AM