Purchase Request Include Screen
Key Lesson: Create an Include screen with an input variable, bind request data to controls, and render related purchase request items.
Create the PurchaseRequestInclude Screen that parent Screens can reuse to display and edit purchase request data. The Screen receives a PurchaseRequest object as an input instead of creating its own request.
1. Create the Include Screen
Section titled “1. Create the Include Screen”- In Design, under Object Types, select Screen.
- Select +.
- Enter
PurchaseRequestIncludeas the Screen ID, then select OK. - Leave the default text component in place temporarily so that the main content area remains populated while you remove the layout wrapper.
-
Save your changes before continuing.
Insight
An Include Screen is designed to be embedded in other Screens. The PurchaseRequestInclude name follows the [ScreenName]Include convention and identifies the Screen as the reusable purchase request interface.
1.1. Remove the MainLayout wrapper
Section titled “1.1. Remove the MainLayout wrapper”The parent Screen already supplies MainLayout. Remove this wrapper from the Include Screen so that embedding it does not create a second application header and sidebar.
- Locate the Screen Purchasing.MainLayout label in the layout editor.
- Click the label to select the
MainLayoutcomponent. - Confirm that only the
MainLayoutcomponent is highlighted and that none of its child components are highlighted. - Right-click the selected component and select Delete & keep children.
- Confirm that Screen Purchasing.MainLayout is no longer displayed.
- Confirm that the Content Area components together with their children remain in the layout editor.
- Save your changes before continuing.
Tip
If you delete the wrong component and have not saved the change, press F5 once or close the editor without saving to restore the last saved version. This discards every unsaved change in the Screen.
2. Define the screen variable
Section titled “2. Define the screen variable”Create the input that receives a purchase request from the parent Screen.
- Open the Variables tab.
- Select + Add new variable.
- Configure the variable as follows:
| Property | Value | Purpose |
|---|---|---|
| Name | request | Identifies the variable used by this Screen's bindings. |
| Context | Input | Allows a parent Screen to pass the request into this Include Screen. |
| Type | | Matches the PurchaseRequest Entity created in the previous stage. |
| Default expression | (Leave blank) | The parent Screen supplies the value. |
-
Save your changes before continuing.
3. Add the Cost Center control
Section titled “3. Add the Cost Center control”- Return to the Layout tab.
- In the VARIABLES panel, expand
request. - Drag
request.costCenterinto the main content area and drop it on the green placeholder.
Editor Help
When dragging a component or variable onto a screen, Lowgile displays a green placeholder indicating where the element can be dropped.
- Select the generated dropdown and configure it as follows:
| Property | Value | Purpose |
|---|---|---|
| Label | Cost Center | Identifies the value for the user. |
| Binding | | Reads and updates the Cost Center on the request received from the parent Screen. |
- Delete the temporary text component. Leave the top-right content area unchanged; it does not need to be removed for this Screen to work.
-
Leave all other properties at their default values.
-
Save your changes before continuing.
If request does not appear in the Variables panel after it has been saved, press F5 once to reload the Screen editor. If costCenter is still missing, compare the variable type with This.PurchaseRequest and verify the Entity in Create Purchase Request Entities.
4. Create the Screen layout
Section titled “4. Create the Screen layout”Create one vertical outer layout for the Cost Center control, the purchase request item collection, and the Add Item action.
- Select the Cost Center dropdown and choose Wrap with Layout. Alternatively, add a Layout to the main content area and move the dropdown into it.
- Set the outer Layout’s Layout property to vertical in one column.
- Select the Cost Center dropdown inside the outer layout and wrap it in a second Layout.
- Set the inner Layout’s Layout property to horizontal in one row. This prevents the dropdown from expanding to the full width of the outer vertical layout.
- Confirm that the horizontal layout contains only the Cost Center dropdown and remains inside the outer vertical layout.
-
Leave all other properties at their default values.
-
Save your changes before continuing.
Editor Help
For faster layout editing, see Screen Editor Shortcuts.
5. Render the purchase request items
Section titled “5. Render the purchase request items”The items relationship is exposed as a collection on screen.request. Render that collection with a For Loop so that each purchase request item has its own set of controls.
- In the VARIABLES panel, expand
screen→request. - Drag
items[]into the outer vertical layout, below the horizontal Cost Center layout. - Lowgile creates a For Loop and a Data Table. Delete the Data Table; this tutorial uses the For Loop.
- Select the For Loop and verify these properties:
| Property | Value |
|---|---|
| Array expression | |
| Loop variable | item |
| Loop variable type | |
Attention
The For Loop must be a direct child of the outer vertical layout, not a child of the horizontal Cost Center layout.
If items[] is unavailable, verify both directions of the relationship in Define the Purchase Request Relationship before continuing.
5.1. Add the item controls
Section titled “5.1. Add the item controls”When the For Loop is selected, its item variable represents the current PurchaseRequestItem.
- Select the For Loop.
- In the VARIABLES panel, expand
item. - Drag
description,quantity,budgetAmount, andcurrencyinto the For Loop’s content area. - Configure the generated controls as follows:
| Variable | Label | Control setting | Value |
|---|---|---|---|
| description | Description | Binding | |
| quantity | Quantity | Binding | |
| budgetAmount | Budget Amount | Binding | |
| currency | Currency | Binding | |
| currency | Currency | Options list source | Static Entity |
| currency | Currency | Options list StaticEntity | Purchasing.Currency |
-
Leave all other properties at their default values.
-
Save your changes before continuing.
Attention
Bind each control to the loop-scoped item variable. A binding to the full screen.request.items collection does not identify the current item.
6. Add the Add Item action
Section titled “6. Add the Add Item action”- Add a Button below the For Loop and keep it outside the loop.
- Configure the button as follows:
| Tab | Property | Value |
|---|---|---|
| Properties | Prefix icon | add |
| Properties | Text | Add Item |
| Appearance | Color | Primary |
| Events → Click | Action type → Ad-hoc action | |
- Wrap the button in a horizontal Layout directly below the For Loop.
-
Leave all other properties at their default values.
-
Save your changes before continuing.
The action adds an empty PurchaseRequestItem to screen.request.items. The For Loop then renders controls for the new item.
Verify the Include Screen configuration
Section titled “Verify the Include Screen configuration”- In Design, open
PurchaseRequestInclude. - Confirm that its
requestvariable uses Input context and typeThis.PurchaseRequest. - Confirm that the Screen does not contain its own
MainLayoutwrapper. - Confirm that the Cost Center dropdown binds to
screen.request.costCenterand the For Loop usesscreen.request.items.
PurchaseRequestInclude accepts a This.PurchaseRequest input, contains no MainLayout wrapper, and binds its Cost Center and item collection to that request.
If a value differs, compare the input, bindings, collection, and layout configuration above before continuing.