Save button

Always use a Save button with Clear and Delete buttons. The Save button should save the displayed information to one or more tables, clear the window after it saves the record, and should never close the window. When it completes the save operation, the save operation should focus the cursor in the window’s key field.

Example 5: Save button change script

The following example checks whether required fields have been addressed by the user, and attempts to save the record. The err() function ascertains which error occurred, so that the script can display the appropriate message and prompt the user to carry out a specific action.

if required (form IG_Lead_Maintenance) then
	{All required fields have been entered.}
	copy from window 'Lead Maintenance' to table IG_Leads_MSTR;
	save table IG_Leads_MSTR;
	{Find out whether the save was successful.}
	if err()=OKAY then
		restart form;
		focus 'Lead ID' of window 'Lead Maintenance';
	{Find out whether another user changed the record.}
	elseif err()=RECORDCHANGED then
		warning "This record was changed. It will be read again.";
		release table IG_Leads_MSTR;
		change table IG_Leads_MSTR;
		copy from table IG_Leads_MSTR;
	elseif err()=LOCKED then
		{Find out whether another user locked the record.}
		warning "This record is locked by another user.";
	end if;
else
	{Not all required fields have been entered.}
	warning "Please enter all required fields before attempting to save this record.";
end if;


Documentation Feedback