Skip to Content

Shared Criteria

Overview

Binding criteria are used to allow a Vinyl Page link to carry with it keys that filter the data on the target Page. For example, a link from a Categories Page to a Products Page would show the user Products where ProductCategoryId = ProductId. Shared Criteria introduces the ability to leverage these passed in variables in additional ways beyond the WHERE clause.

How to use Shared Criteria Values

SELECT Clauses

The Shared Criteria function accesses the values in the current context. They can be used just like any SQL function. If you include a Column in any data object, the value is placed there as a string. By selecting a Shared Criteria value, it can be also used on subsequent Panels. It becomes real data in your data object and can be joined to, used by Controls, etc.

For example: shared('EmployeeID')

WHERE Clauses

WHERE clauses can contain this Shared Criteria function. If you run the rule outside of the context of your Page (by viewing results, for example) expect the Shared function to return the default 'not found' value for the data type specified.

For example: Where E.EmployeeID = shared('EmployeeID')

CRUD

CRUD rules can be run using Shared Criteria. Inserting or updating using this value in the WHERE or SELECT clauses.

Background Events

User run events that run in the background can include Shared Criteria.

Conditional Formatting

Conditional formatting can take advantage of Shared Criteria passed to the Panel.

Dynamic Substitution

Cell data and Control Labels can access Shared Criteria. For example, include "Welcome to {{CompanyName}}" in a data object cell, or the same in a Control Label.

Note

If you're using cell data, be sure to check Support substitution on the Vinyl Control.

Running without Shared Criteria

If you are using the Shared Criteria function, the data object will still run if the Page or url does not contain a matching criteria. However, you'll need to make sure your WHERE clause or SELECT clause still work if the function returns an empty string.

Default Value when Inserting

When you link to a Page with Shared Criteria, any rows you insert will have the shared value automatically defaulted to columns that have the same name.

Default Value when Editing

When you link to a Page with Shared Criteria, and you switch to an edit state, the Shared Criteria will "default" themselves onto any null columns with the same name.

SQL Runtime Function: Shared

In SQL you access shared criteria via the Shared function. For example:

SELECT CustomerId, shared('ActiveEmployeeId') as ActiveEmployeeId FROM Customer WHERE CustomerRegionId <> shared('LastRegion', 'UUID')

The function returns the Shared value as a string. The function has two parameters:

  • Name: the name of the criteria to look up
  • Data type: if the shared criteria is not found, the return type can be specified as UUID or numeric. If set, Vinyl will return '00000000-0000-0000-0000-000000000000' for a UUID or '0' for a number. Otherwise the resulting SQL will fail when comparing a UUID to an empty string.

Shared Criteria can be specified at the Panel or Field level.

Shared Criteria are only available on page links. These are links that change the URL and open a new Page. The targeted Page will provide these Shared values to all 'root' Panels (Panels not bound to other Panels). Unless you use the Shared function, the targeted Panels won't filter automatically.