The Orders form is required to initialize differently for different users. A database procedure (GET_ROLE_NAME) is used to determine which database roles are enabled for the user logging on to the form. If the user has the STORE_CLERK role enabled, certain buttons are disabled and the focus is sent to the Customer_Id text item. If the user has the ADMIN_MGR role enabled, all buttons are available and the focus is sent to the Date_Ordered text item. The buttons are set by a form-level procedure (SET_BUTTONS).
The functionality is achieved with this code:
If get_role_name(USER) = ‘STORE_CLERK’ THEN
set_buttons(‘STORE_CLERK’);
GO_ITEM(ORDERS.Customer_id’);
ELSE
set_buttons(ADMIN_MGR’);
GO_ITEM(‘ORDERS.Date_Ordered’);
END IF;
What is the best trigger to execute this code?
A.
When-Validate-Item at form level, so that validation takes place as soon as the form initializes.
B.
When-New-Form-Instance, because GO_ITEM is a restricted procedure and cannot be called from any “Pre” triggers.
C.
Pre-Form at form level, because the focus will be set before the items appear so that users do not see the cursor moving around the screen.
D.
When-Button-Pressed on any of the enabled buttons, so that it can still execute.
If it where written against the disabled buttons, it would never be fired for the STORE_CLERK role.
E.
When-New-Item-Instance on the Date_Ordered Text item, because you want to check for the database role and redirect focus away from here if the user is a STORE_CLERK.
F.
Pre-Block on the first navigable block in the form, because it makes sense to redirect the focus just before the cursor enters the block.