I am hoping to create an alert on a form to prompt users to update a value. The duration for the alert needs to be based on a fiscal year. In other words, if the value has not been updated starting 7/1/2015, then it needs to be updated, even if it was last updated on 6/30/2015. Can someone please tell me how to code this in MEL?
I can probably help you with that, but let me confirm what you are after with an example.
It appears you are wanting to alert the user as follows:
From 7/1/2015 until 6/30/2016, you want to prompt the user to enter a value when no value exists with a date later than 6/30/2015.
Once 7/1/2016 occurs, you then want to prompt the user to enter a value when no value exists with a date later than 6/30/2016.
and so on...
Am I understanding you correctly?
I adjusted something I had, you will need to adjust where it says "userok(..." for your needs, I entered "Height" as the observation term as an example.
//use this to run the code every time the document is opened
{!global RunOnce}{!if RunOnce == "" then CheckValue("height") RunOnce = "done" endif}
//use this to run the code once the first time the document is opened
{!global RunEvery}{!if DOCUMENT.RunEvery == "" then CheckValue("height") DOCUMENT.RunEvery = "done" endif}
//include this
{!fn CheckValue(obsterm){
local last = last_signed_Obs_date(obsterm)
local year = sub(str(document.clinicaldate),7,4)
local try = "07/01/" + year
if durationdays(str(document.clinicaldate),try)>0 then
//fiscal year is previous year
year = str(val(year) -1)
try = "07/01/" + year
endif
if durationdays(last,try)>0 then
userok("enter another value")
else
userok("value ok")
endif
return ""
}
}