How Do I Execute Task Prefix/Suffix Logic of a Subform Only on Opening the Subform Task for the First Time by its Parent? (Magic xpa 3.x)
Task prefix executes whenever a task starts, and task suffix executes whenever the task ends. When you are using a subform, the subform task executes once, to display its contents, when the parent task first executes. But it also executes when the parent task is refreshed, and then again when the user actually enters the subtasks. So, if you want to have logic that executes only during this initial execution of the subform task, you need to use the SubformExecMode() function.
If the subform task is opened for the first time, SubformExecMode(0) will return 1. So using
SubformExecMode(0) = 1
as the condition on the block will cause the block to only execute when the subform is called for the first time.
-
Open up a line in the logic unit you are modifying (F4 or Edit->Create Line).
-
Select the Block operation by typing B or by using the pulldown list.
-
Two lines will open up, a Block If and a Block End. Tab to or click on the field after the If.
-
Zoom (F5, double click) to the expression rules. Enter the expression:
SubformExecMode(0)=1
-
Press Enter to select the expression and bring back the expression number.
Now the block will only execute when the subform is executed for the first time.
The Online and Rich Client Samples projects (program SB07 and RSB07)