Hello All,
I am trying to get a handout to autoprint on a a form without a button. I created a watcher function that takes the bmi and if it is over a certain range a handout is called with PRINTHANDOUT(). I also put a value into an obs term indicating that the printout occurred -- this way there isn't a duplicate handout printed. This works great as long as you don't put the document on hold.
I've noticed that bringing the document off of hold causes PRINTHANDOUT() to be called again even though there is a value in the obs term that should prevent this. I ran a mel trace and noticed that the obs term returned a null value. Even though a null value is returned in the mel trace the initial value before I put the visit on hold is returned on the form.
So, I think that obs terms (and document variables since I tried that too) are loaded after any watcher functions. Has anyone coded around this? I'd like to be able to have a flag persist if the visit is put on hold.
Thanks,
Brad
Yes you are correct that observation terms are loaded much later, but I do this all the time with document variables. Just make sure that you are not setting the document variable with the observation term or you may have the same issue, I usually do something like this -
{!if DOCUMENT.ALREADYPRINTED == "" then
IF DOCUMENT.CRITERIA == TRUE then
//do this
DOCUMENT.ALREADYPRINTED = "Yes"
ENDIF
endif}
{OBSNOW("OBSTERM",DOCUMENT.ALREADYPRINTED)}
Yes you are correct that observation terms are loaded much later, but I do this all the time with document variables. Just make sure that you are not setting the document variable with the observation term or you may have the same issue, I usually do something like this -
{!if DOCUMENT.ALREADYPRINTED == "" then
IF DOCUMENT.CRITERIA == TRUE then
//do this
DOCUMENT.ALREADYPRINTED = "Yes"
ENDIF
ENDIF}
{OBSNOW("OBSTERM",DOCUMENT.ALREADYPRINTED)}
Thank you for the explanation. I looked at my attempt using a document variable again and found a type-o in the code that was preventing the document variable from being assigned. It is interesting that the obs terms load after other code. You would think all of the data that code might need to access would load first.