Create a custom data type called PurchaseRequestItem with the following fields:
id (Number (Integer))
qty (Number (Integer))
unitPrice (Number (Decimal))
Designate the id field as the primary key and set to generate value.
Save and publish the CDT.
Create a Data Store called "Purchase Request" with two entities, one of each data type that was just created:
Insert the following values into PurchaseRequest:
Insert the following values into PurchaseRequestItem:
Now that we have the data, let's create a couple of supporting constants:
PR_ENTITY: A constant of type Data Store Entity with value PurchaseRequests.
PR_ITEM_ENTITY: A constant of type Data Store Entity with value PurchaseRequestItems.
Now that we have created all of the supporting objects, let's move on to the main expression.
Test it out
Click on "+ PR 1" in the "Summary" column to expand to show the item rows corresponding to PR 1.
Click on "- PR 1" to hide the item rows for PR 1 again.
The same can be done for PR 2.
Notable implementation details
Notice that we used a rich text display component to create a dynamic link used to expand and collapse the item rows for each purchase request. Alternatively, we could have used a link component containing the same dynamic link. The rich text display component would be useful here if a rich text style (e.g. underline) needed to be applied to the purchase request summary or if the summary needed to be a combination of links and normal text.
The bullet appearing in front of each item summary is made possible by using a rich text bulleted list within a rich text display component. See also: Rich Text
We left the selection parameter blank in our a!query()function because we wanted to return all fields of the entities that we were querying.