What is DoModal?

Syntax
DoModal(PAGE.pagename, title, xpos, ypos,
[level, scrollpath, target_row])
where scrollpath is:
[RECORD.level1_recname, level1_row, [RECORD.level2_recname, level2_row, ]] RECORD.target_recname

To prevent ambiguous references, you can also use SCROLL.scrollname, where scrollname is the same as the scroll level?s primary record name.

Description

The DoModal function displays a secondary page. Secondary pages are modal, meaning that the user must dismiss the secondary page before continuing work in the page from which the secondary page was called.

If you call DoModal without specifying a level number or any record parameters, the function uses the current context as the parent.
You can alternately specify a secondary page in a command push button definition without using PeopleCode. This may be preferable for performance reasons, especially with Web client code.

DoModal can display on a single page. If you want to display an entire component modally, use DoModalComponent.

Any variable declared as a Component variable will still be defined after using a DoModal function.

Returns

Returns a number that indicates how the secondary page was terminated. A secondary page can be terminated by the user clicking a built-in OK or Cancel button, or by a call to the EndModal function in a PeopleCode program. In either case, the return value of DoModal is one of the following:

? 1 if the user clicked OK in the secondary page, or if 1 was passed in the EndModal function call that terminated the secondary page.

? 0 if the user clicked Cancel in the secondary page, or if 0 was passed in the EndModal function call that terminated the secondary page.

Parameters
- pagename The name of the secondary page.
- title The text that will be displayed in the caption of the secondary page.
- xpos, ypos The pixel coordinates of the top left corner of the secondary page, offset from the top left corner of the parent page (the default of -1, -1 means centered).
- level Specifies the level of the scroll level on the parent page that contains the row corresponding to level 0 on the secondary page.
scrollpath A construction that specifies a scroll level in the component buffer.
- target_row The row number of the row in the parent page corresponding to the level 0 row in the secondary page.

Restrictions on Use in PeopleCode Events

Control does not return to the line after DoModal until after the user has dismissed the secondary page. This interruption of processing makes DoModal a "think-time" function, which means that it shouldn?t be used in any of the following PeopleCode events:
? SavePreChange
? SavePostChange
? Workflow
? RowSelect
? Any PeopleCode event that fires as a result of a ScrollSelect, ScrollSelectNew, RowScrollSelect or RowScrollSelectNew function call.

Restrictions on Use with a Component Interface

This function can?t be used by a PeopleCode program that?s been called by a Component Interface. You should put a condition around this function, testing whether there?s an existing Component Interface or not.
If %CompIntfcName Then
/* process is being called from a Component Interface */
/* do CI specific processing */
Else
/* do regular processing */
. . .
End-if;

Example

DoModal(PAGE.EDUCATION_DTL, MsgGetText(1000, 167, "Education Details - %1", EDUCATN.DEGREE), - 1, - 1, 1, RECORD.EDUCATN, CurrentRowNumber());


Use the DoModalComponent function to launch a modal component. The modal component launches from within an originating component. After the modal component displays, the user can’t proceed with changes to the originating component until either accepting or canceling the modal component.
Essentially, you are requesting a specific page on a component to be opened from an existing component say on a click of a button. So you need another component defined with a page that you want opened when the method is invoked.

Subpages becomes part of a page and do not have an identity of its own. Generally, all the fields on a sub page are part of a sub record.For e.g. an address subpage. 

Secondard pages generally are placed on the Page itself and opened up when the user clicks a link button on a page on when the seondard page is placed. one could use a do modal to open a secondard page. Generally used when, real estate on a page is insufficient and you want to move some fields generally not touched by users on s separate secondary page. 

I sugguest you try to create pages, components etc and you will get an idea of what is happening. Just reading peoplebooks will not help. 

Part of it is because of how Peoplebooks is organized.
For e.g. all the function are organized alphabetically and just reading a function in isolation will not be be very helpful. ( unfortunately. ) 

Maybe start building simple pages and components . For the issue at hand, creat 2 components with pages attached to each andthe call domodalComponent from one. Try calling a sub page or a secondard page using the function and you will know why that function cannot be used.


The IsModal function returns True if executed from PeopleCode running in a modal secondary page and False if executed elsewhere. This function is useful in separating secondary page-specific logic from general PeopleCode logic.