Return the List of Items the Current Item Is Referenced by
You can see link relationships of an item. For example, if you send a request to purchasing department for stationery, you may want the all related invoices to be shown in the workflow item representing this request. The real difficulty in showing invoices may arise, if the invoices reference the request, but the request doesn't reference invoices. Use the below example to avoid difficulties in this respect.
To create the list of the items the current item is referenced by:
1. Assuming that you have the previously created «Purchase Request» and «Invoice» applications, go to the respective workspace and open the «Invoice» app.
2. Click «Fields».
3. Find the required field, which provides adding links to other items, and copy its identifier. For example, the «Related to» field (ID: Related_to).
4. Go to the «Purchase Request» app and click «Fields».
5. Create the «Is referenced by» field of the Reference type, intended to show the list of items, which reference the current workflow item. Select the «Multiple values» and «Calculated» check boxes. Type the following expression in the «Field Expression» tab:
$<-Related_to |
The above expression returns the list of invoices, which have a link to our request in the «Related to» field.
6. Click «Save».
Open an existing request to verify whether the expression works correctly. A list of related invoices should be shown in the «Is referenced by» field.
Let’s go further and get the list of types of invoices the current item is referenced by.
To get the list:
1. Open the «Invoice» app and click «Fields».
2. Find the required field intended to contain the type of invoice, and copy its identifier. For example, the «Invoice type» field of the List of Values type (ID: Invoice_Type).
3. Go to the «Purchase Request» app and click «Fields».
4. Create the «Type of Related Invoice» field with the same properties as the «Is referenced by» field has. Modify our expression as follows:
$<-Related_to<-Invoice_Type |
5. Type the expression in the «Field Expression» tab.
6. Click «Save».
Open an existing request to see the result. The list of types of related invoices should be shown in the «Type of Related Invoice» field.
You can change the direction of arrows in the expression in order to get the list of types of items, which referenced by the current request.
$->Related_to->Item_Type |