Tips & Tricks - Displaying Records Based on Permissions

This post shows how data sets can be displayed based on permissions. A solid knowledge of Intrexx and SQL is required. Enable the expert options so that all the dialog boxes mentioned in this example are accessible. Intrexx GmbH does not provide support for errors resulting from incorrect implementation and assumes no liability for such errors.

A common way to grant access permissions for individual records is to add a text data field to the data group containing the records to be restricted, to which user objects are assigned using a distribution control.

A filter is then defined in a view table associated with the application; this filter compares the currently logged-in user with the set of user objects stored in the text data field and checks whether that user is authorized to read the record. Although this type of filtering achieves the desired result, it is not recommended from a performance standpoint. Especially on portals with a large number of users and groups, loading times can sometimes be very long when a page is opened.

Comparing values with those in child data groups results in a significant performance gain. In this process, user objects with access permissions are stored in a child data group and mapped using a foreign key filter with a subselect.

To do this, use the "Multiple Selection" element on any input page within the data group for which access permissions are to be set. In the Properties dialog box for the multiple selection, on the "Data Source" tab, select the "Distribution Selection" option.

On the "Storage Options" tab, select the "Data Group" option. Clicking "Create New Child Data Group" at creates a new child data group. This data group is automatically named "Distribution Control Values." Three data fields are also created automatically:

  • PK – Primary Key: The unique key for the new data group.

  • FK – Foreign Key: Corresponds to the primary key of the parent record for which an authorization is to be stored.

  • Distribution List – Stored Value: This data field stores the user object that the user selected in the distribution list selection in the browser. If multiple objects are selected, a corresponding number of data records is created in the child data group.

Now you need to edit the filter's XML in the desired view table.

Go to the page containing the table you want to filter, and open the table's Properties dialog box. On the "Data" tab, click "Filter," and then click "Edit Filter in Expert Mode."

            <filter guid="EFC6F080E119E0D3AD5B8C9E0458EDE8054AFA0A">   
	<exp op="" type="in">      
		<arg content="GUID_1" type="fieldguid"/>      
		<arg type="statement">         
			<select content="GUID_2" type="tableguid">            
				<field content="GUID_3" type="fieldguid"/>            
				<conc op="and">
					<exp op="" type="in">
						<arg content="GUID_4" type="fieldguid"/>                  
						<arg content="orgstruct" type="userattribute"/>               
					</exp>
				</conc>        
			</select>
		</arg>
	</exp>
</filter>

        

When you open the editor, a <filter> element is already defined. Keep this and remove the closing symbol / at the end of the element. Then paste the rest of the script shown above, excluding the first line. Replace the following values:

  • GUID_1: GUID of the primary key data field in the parent data group

  • GUID_2: GUID of the child data group "Value Distribution Check"

  • GUID_3: GUID of the foreign key data field in the child data group

  • GUID_4: GUID of the "Distribution List" data field in the child data group

After saving the application, you can test it in your browser by creating records for different users and then logging in to the portal accordingly.