Displaying an alert notifying a user of missing data and setting field focus

In this HR11 scenario, a user chooses a Terminated status (TM) for an employee in Drill Select. The custom function checks to see that the Termination date has been set, if not, an alert is displayed notifying the user that it is required.

With the await in place, code execution is paused until the user clicks OK on the dialog, and then resume, setting focus on the intended field. If we do not use the async/await keywords here, execution would continue through while the dialog is still on the screen, and focus would be set to the dialog, not the _f292 field. Note: this behavior is for 10.1.0.29+ of Lawson Portal and Infor Lawson Design Studio.

async function TEXT_OnAfterDrillSelect(id, keysNode, row) {

    if (id === 'text12') 
    {
        const ds = new portalWnd.DataStorage(keysNode);
        if (ds.getElementCDataValue('KEYFLD') === 'TM') 
	  {
            const terminationDate = lawForm.getElementValue('_f292');
            if (!terminationDate) 
		{
const message = 'A termination status requires a termination date';
                await portalWnd.cmnDlg.messageBox(message , 'ok');
                lawForm.positionInField('_f292');
            }
        }