In this step, you will add logic to the Employee Note Editor Pop Up to:
1. Copy the Group_By definition xEmployeeNotes from the iiixEmployeeNotesDataServer into your Employee Note Editor reusable part.
2. Create a Show method routine with three inputs:
NoteGUID with a class of xEmployeeNoteGUID
EmployeeID with a class of xEmployeeIdentification
FullName with a class of iiiFullName
Your code should look like the following:
Mthroutine Name(Show)
Define_Map For(*INPUT) Class(#xEmployeeNoteGUID) Name(#NoteGUID)
Define_Map For(*INPUT) Class(#xEmployeeIdentification) Name(#EmployeeID)
Define_Map For(*INPUT) Class(#iiiFullName) Name(#FullName)
Endroutine
3. In the web page, define a work field CurrentNoteGUID based on field xEmployeeNoteGUID
Define Field(#CurrentNoteGUID) Reffld(#xEmployeeNoteGUID)
4. Complete the Show routine based on the following:
Define a component for iiixEmployeeNotesDataServer / Find srvroutine,name GetNote.
Assign CurrentNoteGUID the value NoteGUID
Assign xEmployeeIdentification the value EmployeeID
Set #Text1.text to blank
Execute GetNote asynchronously exchanging field NoteGUID, Group_By xEmployeeNotes and field IO$STS.
Within and event routine for GetNote.Completed,
If IO$STS = OK
Set component Caption to 'Employee ' + EmployeeID + " " + FullName
Set Text1.text = #xEmployeeNote
Invoke component ShowPopup
End If
End Routine
Your completed code should look like the following:
Mthroutine Name(Show)
Define_Map For(*INPUT) Class(#xEmployeeNoteGUID) Name(#NoteGUID)
Define_Map For(*INPUT) Class(#xEmployeeIdentification) Name(#EmployeeID)
Define_Map For(*INPUT) Class(#iiiFullName) Name(#FullName)
Define_Com Class(#iiixEmployeeNotesDataServer.find) Name(#GetNote)
#CurrentNoteGUID := #NoteGUID
#xEmployeeIdentification := #EmployeeID
#Text1.text := " "
#GetNote.Executeasync( #NoteGUID #xEmployeeNotes #IO$STS )
Evtroutine Handling(#GetNote.Completed)
If (#IO$STS = OK)
#COM_OWNER.Caption := 'Employee ' + #EmployeeID + " " + #FullName
#Text1.Text := #xEmployeeNote
#com_owner.ShowPopup
Endif
Endroutine
Endroutine
5. Define event uCompleted which passes the value of fields xEmployeeNoteGUID, xEmployeeIdentification and xEmployeeNote. Define the event following other definition statements (Define_Com).
Your code should look like the following:
Define_Evt Name(UCompleted)
Define_Map For(*INPUT) Class(#xEmployeeNoteGUID) Name(#NoteGUID)
Define_Map For(*INPUT) Class(#xEmployeeIdentification) Name(#EmployeeID)
Define_Map For(*INPUT) Class(#xEmployeeNote) Name(#EmployeeNote)
6. Create a SaveNote method routine. Complete the code, based on the following:
Define a component for iiixEmployeeNotesDataServer / Save srvroutine, name SaveNote
Assign xEmployeeNoteGUID to CurrentNoteGUID
Assign xEmployeeNote to Text1.Text property
Execute component SaveNote asynchronously, exchanging Group_by xEmployeeNotes and field IO$STS
Within an event routine for SaveNote.Completed:
If IO$STS is OK,
Signal uCompleted event, setting values for all parameters
Invoke component ClosePopup
Endif
End Routine
Your code should look like the following:
Mthroutine Name(SaveNote)
Define_Com Class(#iiixEmployeeNotesDataServer.save) Name(#SaveNote)
#xEmployeeNoteGUID := #CurrentNoteGUID
#xEmployeeNote := #Text1.Text
#SaveNote.ExecuteAsync( #xEmployeeNotes #IO$STS )
Evtroutine Handling(#SaveNote.Completed)
If (#IO$STS = OK)
Signal Event(uCompleted) Noteguid(#CurrentNoteGUID) Employeeid(#xEmployeeIdentification) Employeenote(#xEmployeeNote)
#COM_OWNER.ClosePopup
Endif
Endroutine
Endroutine
7. Invoke the SaveNote method from the push button Save.Click event routine.
Evtroutine Handling(#Save_Note.Click)
#com_self.SaveNote
Endroutine
8. Compile the Note Editor Popup component.