Hi everyone,
I want to figure out how to get the last date of an obsterm by a specific user (more specifically, the logged in user). I know there is LASTOBSVALULEBYUSER, but there is no equivalent for date. I tried running a for-loop that uses "LIST_OBS" in its delimited form, but I'm struggling to match the user to the date of the obs.
Does anyone have any experience with this?
Thanks for any help,
Sarah
Sarah
Using LIST_OBS you could grab the signed user and compare this against the current user (USER.REALNAME):
{fn GetLastUserObsDate(obs){
local lObsArr,lCount,lResult
lResult = ""
/* Create array of observations */
lObsArr = getfield(LIST_OBS(obs,"signed","delimited","value"),"|","")
for lCount=1, lCount <= size(lObsArr), lCount = lCount + 1 do
/* Create an array for each observation */
lObsArr[lCount] = getfield(lObsArr[lCount],"^","")
/* Find latest signed observation from current user */
if lObsArr[lCount][4] == USER.REALNAME then
/* Set date of observation */
lResult = lObsArr[lCount][2]
BREAK
else ""
endif
endfor
return lResult
}}
Thank you so much! It worked perfectly!