Hi Stephen,
Thank you for your reply, this is very weird. So just to provide some additional background on the triggers etc. we are using this for our building assistance center and the trigger on the notification is when a WO status for BAC is changed to COMP. Within the template it has the following configuration 
in the escalations component the condition is as follows
changedate > '2022-05-13' and status in ('COMP') and exists (select 1 from workorder where workorder.wonum = wostatus.wonum and workorder.siteid = wostatus.siteid and workorder.origrecordclass = 'SR')
The escalation template then has a notifications configuration which pulls in the COMM Template.
So when I change a WO to COMP it will trigger the above and I get the mail as designed. The mail I get has the following info configured in the COMM template
Completion Log :
Below are the details of the last worklog entry:
Summary Description: :WORKORDER.WORKLOG.description
Summary Details: :WORKORDER.WORKLOG.description_longdescription
In the email I do get the values for description and long description from the log in the closed WO. So if I have the following log entries
I should get the last log entry dated today for example the AMBROWN item. But no matter how I switch it up I always get the last entry so for the example above I end up with the EFRAI10X the DSP item.
In the WORKORDER Databased configuration I have a relationship for WORKLOGCOMP and in the where clause I did have the following
class=:woclass and worklogid=(select MAX(worklogid) from worklog where recordkey=:wonum) and then I changed it to
RECORDKEY=:WONUM AND CLASS=:WOCLASS AND WORKLOGID IN ( SELECT WORKLOGID FROM WORKLOG WHERE CREATEDATE = ( SELECT MAX(CREATEDATE) FROM WORKLOG WHERE RECORDKEY= :WONUM AND CLASS=:WOCLASS ))
I have tried both queries in the Maximo DB via Microsoft SQL Server Management and each item I get the correct answer i.e. the AMBROWN entry but when I try to trigger it via closing a WO. I always get the oldest record and I cant figure out if there is some other configuration that is reverting the result.
------------------------------
andrew brown
Intel
------------------------------
Original Message:
Sent: 02-27-2025 09:25
From: Stephen Hume
Subject: Where Clause in Database Configuration
Andrew here is a query I use in a relationship to get the latest worklog entry for an SR.
RECORDKEY=:TICKETID AND CLASS=:CLASS AND WORKLOGID IN ( SELECT WORKLOGID FROM WORKLOG WHERE CREATEDATE = ( SELECT MAX(CREATEDATE) FROM WORKLOG WHERE RECORDKEY= :TICKETID AND CLASS=:CLASS ))
for work order to get the OLDEST entry it can be changed to
RECORDKEY=:WONUM AND CLASS=:WOCLASS AND WORKLOGID IN ( SELECT WORKLOGID FROM WORKLOG WHERE CREATEDATE = ( SELECT MIN(CREATEDATE) FROM WORKLOG WHERE RECORDKEY= :WONUM AND CLASS=:WOCLASS ))
I have tested this in my demo Maximo and it is getting the oldest worklog entry.
If you instead want the most recent worklog entry then change MIN to MAX in the whereclause above
------------------------------
Stephen Hume
Sheffield Scientific LLC
------------------------------