Step 3. Improve Performance

You used an existing srvroutine to retrieve all data for all employee notes. This is retrieving unwanted data, which increases the amount of data to be sent to the web page. You will now create a new srvroutine in server module iiixEmployeeNotesDataServer, which returns a smaller working list.

1.  Open the server module, iiixEmployeeNotesDataServer in the editor. Define the following working list:

Def_List Name(#xEmployeeNotesBrief) Fields(#xEmployeeNoteGUID #xEmployeeIdentification #xEmployeeNoteCreateUpdate #xEmployeeNote) Type(*Working) Entrys(*MAX)

2.  Create a new srvroutine FindNotesOnly which performs the following:

Define an output for xEmployeeNotesBrief list

Select xEmployeeNotes list from the table xEmployeeNotes

Add each entry to xEmployeeNotesBrief

End Select

     Your code should look like the following:

Srvroutine Name(FindNotesOnly)

List_Map For(*OUTPUT) List(#xEmployeeNotesBrief)

Select Fields(#xEmployeeNotesBrief) From_File(xemployeenotes)

Add_Entry To_List(#xEmployeeNotesBrief)

Endselect

Endroutine

3.  Compile the server module.

4.  Copy the list definition xEmployeeNotesBrief to the Windows clipboard.

5.  Switch to the iiiListTree web page in the editor. Paste the list definition xEmployeeNotesBrief to the web page, before the routines.

6.  Locate the GetNotes routine. Replace xEmployeeNotesList with xEmployeeNotesBrief.

Mthroutine Name(GetNotes)

Define_Com Class(#iiixEmployeeNotesDataServer.findall) Name(#GetNotes)

#GetNotes.EXECUTEASYNC( #xEmployeeNotesBrief )

Evtroutine Handling(#GetNotes.Completed)

#COM_SELF.LoadDepts

Endroutine

Endroutine

7.  Locate the LoadNotes routine. Replace list xEmployeeNotesList with xEmployeeNotesBrief.

Mthroutine Name(LoadNotes)

Define_Map For(*INPUT) Class(#xEmployeeIdentification) Name(#EmployID)

Define_Map For(*INPUT) Class(#prim_list.listitem) Name(#parent) Pass(*BY_REFERENCE)

* #sys_web.Alert( #xEmployeeIdentification )

Selectlist Named(#xEmployeeNotesBrief) Where(#EmployID = #xEmployeeIdentification)

 

#COM_SELF.AddEntry( #xEmployeeNoteCreateUpdate.AsDisplayString #xEmployeeNote.AsNativeString.trim "" #xImageDetails32 #parent )

Endselect

Endroutine

8.  Compile and test your web page. You should now notice a few seconds improvement in the initial web page load.