I have a form (ABC) where I want to add a lookup button to pre-fill some fields with typically used values stored in unrelated table. It contains some commonly used remarks, so I want to allow user to choose one of a few remarks instead of retyping every time, however this is not mandatory, user can choose to type own custom remark not listed in remarks table. I do it with this code
OF ?ButtonCallLookup
GlobalRequest = SelectRecord
BrowseRemarks()
IF GlobalResponse = RequestCompleted THEN
....
! Assigning field values
....
DISPLAY()
END
However, this approach setās the GlobalRequest and GlobalResponse for the calling form causing some undesired behaviour when trying to cancel after calling lookup.
Template generated lookups do it this way, using run method
IF SELF.Run(1,SelectRecord) = RequestCompleted
....
! Assigning field values
....
ELSE
CLEAR(PRE:Myfield)
SELECT(?PRE:MyField)
CYCLE
END
And the lookup procedure is defined in the run method code
ThisWindow.Run PROCEDURE(USHORT Number,BYTE Request)
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.Run(Number,Request)
IF SELF.Request = ViewRecord
ReturnValue = RequestCancelled ! Always return RequestCancelled if the form was opened in ViewRecord mode
ELSE
GlobalRequest = Request
BrwMyTable1 ! subordinate procedure number 1
ReturnValue = GlobalResponse
END
RETURN ReturnValue
How do I add my BrowseRemarks procedure to be called as number 2 ?