Field focus triggers

Most fields have three focus events with which you can use a focus trigger. However, button fields activate triggers for the change focus event only. The following table explains each field focus event, and the corresponding value of the focus_type parameter required in the Trigger_RegisterFocus() function:

[spacer]

Focus event

Description

Value of focus_type

pre

Occurs when the focus moves to the field.

TRIGGER_FOCUS_PRE

change

Occurs when the content of the field changes. If the field is a button, the focus event occurs when the button is clicked.

TRIGGER_FOCUS_CHANGE

post

Occurs when the focus moves from the field.

TRIGGER_FOCUS_POST

context menu

Occurs when the context menu for the field is displayed

TRIGGER_FOCUS_CONTEXT_MENU


Example 8: Field focus trigger

This trigger is activated when the user clicks the Save button in the Customer Maintenance window.

{Name: Startup}
local integer l_result;

l_result = Trigger_RegisterFocus(anonymous('Save Button' of window RM_Customer_Maintenance of form RM_Customer_Maintenance), TRIGGER_FOCUS_CHANGE, TRIGGER_BEFORE_ORIGINAL, script IG_Check_Contact_Date);
if l_result <> SY_NOERR then
	warning "Trigger registration failed.";
end if;

This trigger processing procedure displays a warning dialog if the user hasn’t contacted the customer in the prior month.

{Name: IG_Check_Contact_Date}
local integer l_days;

if isopen(window RM_Customer_Maintenance of form RM_Customer_Maintenance) then
	{Retrieve a contacts record and check the last contact date.}
	'Customer Number' of table IG_Contact_History_MSTR = 'Customer Number' of window RM_Customer_Maintenance of form RM_Customer_Maintenance;
	release table IG_Contact_History_MSTR;
	change table IG_Contact_History_MSTR by IG_Contact_History_MSTR_Key1;
	if err()=OKAY then
		if not empty('Last Contact Date' of table IG_Contact_History_MSTR) then
			if 'Last Contact Date' of table IG_Contact_History_MSTR <= (sysdate()-30) then
				l_days = abs(integer(date('First Contact Date' of table IG_Contact_History_MSTR) - sysdate()));
				warning "It's been " + str(l_days) + " days since you contacted this customer.";
			end if;
		end if;
	end if;
end if;


Documentation Feedback