Implementing Modal Transfers
Any component accessible through an application menu system can be accessed using a modal transfer. However, to implement a modal transfer, you must modify pages in both the originating component and the modal component. After these modifications are complete, you can implement the modal transfer using the DoModalComponent function from a page in the originating component.
Before beginning this process, you should answer the following questions:
-
Should the originating component provide search key values for the modal component?
If so, what are the search keys? (Check the modal component's search record.)
-
Does the originating component need to pass any data to the modal component?
If so, what record fields are needed to store this data?
-
Does the modal component need to pass any data back to the originating component?
If so, what record fields are needed to store this data?
To implement a modal transfer:
-
Create derived/work record fields for sharing data between the originating and modal components.
Create a new derived/work record or open an existing derived/work record. If suitable record fields exist, you can use them; otherwise create new record fields for any data that needs to be shared between the components. These can be search keys for the modal component, data to pass to the modal component, or data to pass back to the originating component.
-
Add derived work fields to the level-zero area of the originating component.
Add one edit box for each of the derived/work fields that you need to share between the originating and modal components to the level-zero area of the page from which the transfer will take place. You probably want to make the edit boxes invisible.
-
Add the same derived work fields to the level-zero area of the modal component.
Add one edit box for each of the edit boxes that you added in the previous step to the level-zero area of the page to which you are transferring. You probably want to make the edit boxes invisible.
-
Add PeopleCode to pass values into the derived/work fields in the originating component.
To provide search key values or pass data to the modal page, write PeopleCode that assigns appropriate values to the derived/work fields before DoModalComponent is called.
For example, if the modal component search key is PERSONAL_DATA.EMPLID, you could place the following assignment statement in the derived/work field's RowInit event:
EMPLID = PERSONAL_DATA.EMPLIDYou also might assign these values in the same program where DoModalComponent is called.
-
Add PeopleCode to access and change the derived/work fields in the modal component.
No PeopleCode is required to pass search key values during the search. However, if other data has been passed to the modal component, you may need PeopleCode to access and use the data. You may also need to assign new values to the shared fields so that they can be used by the originating component.
It is possible that the component was accessed through the menu system and not through a modal transfer. To write PeopleCode that runs only in the component when it is running modally, use the IsModalComponent function:
If IsModalComponent() Then /* PeopleCode for modal execution only. */ End-If -
Add PeopleCode to access changed derived/work fields in the originating component.
If the modal component has altered the data in the shared work fields, you can write PeopleCode to access and use the data after DoModalComponent has executed.
Note:
You can use the EndModalComponent function as a programmatic implementation of the OK and Cancel buttons.