Record validation before save - Legacy code

I have a GLOBAL variable indicating whether a user can schedule a date using a particular machine. I want to check the value of the global variable (1: allow or 0: dont allow) for a particular machine and if that machine has been selected in the drop down list.

I am using code like this to test the whether the user has permission to use the machine (GLO:Machine is set as the machine is selected from the list box) :frowning:

IF GLO:Laser_Qual = 0 AND GLO:MachineName = 'Laser' AND GLO:Admin = 0
    MESSAGE('You are not qualified on the Laser' & '|' & 'and cannot schedule time on the machine.')
    CLEAR(Sch:MachineName)
    DO RefreshWindow
    RETURN
END

I cannot seem to get the window to stay open and require the user to select a machine that they can use. The window just closes and saves the record.

Sorry for the basic questions … I am trying to relearn after 10 years.

Late addition to question: I was trying to do this on the ?OK Accepted Embed

thoughts?

It’s been longer than 10 years since I used legacy, so this may be the blind leading the blind, but if your window is closing unexpectedly, maybe it is the RETURN causing it?

1 Like

I would concur with JonW. Return will cause you to exit the entire procedure. I suggest you instead replace it with a SELECT(?) which will return you to the original window for further action.

Not sure if this would help, but if this was ABC I’d say use takecompleted before parent.
I have no idea what embed that is in legacy

Open your dictionary and search for the field in global variable of the dictionary and then check the attribute for that field, you will find default value .

thanks all … I did a reconfiguration of the data files to take a different approach. Sessions are now a child file to a file containing Machine/date fields.