nextField() is used to specify the name of the field to which the cursor must go when the program control returns to the dialog. The method performance is similar to that of the NEXT FIELD statement, but it does not break the program workflow.
There is some specifics about using variables with ui.Dialog methods.
You can learn about them here.
nextField() needs an argument which specifies the target field name. Therefore, the target field can be changed at runtime depending on the situation (key press, values, privileges, etc.).
DEFINE str STRING,
field1, field2 STRING
...
ON ACTION ("switch")
IF str = check_val THEN
CALL DIALOG.nextField(field1)
CONTINUE DIALOG
ELSE
CALL DIALOG.nextField(field2)
CONTINUE DIALOG
END IF
CALL save_changes()