Hi everyone!
I'm having a bit of trouble getting this useryesno function to do exactly what I want. Basically, I want it to pull what was previously entered in a multi-line edit field, prompt the user to insert it or not, and if yes insert the previous string into the multi-line edit field along with whatever is currently entered in the document variable.
I've managed to pull up the useryesno window with the previous obs displayed correctly, but once I click "yes" I can't get it to output to the edit field.
Here's the code for my function:
{
fn PHPI_view_insert_prior1()
{
IF (obsprev("PROG1ADDINFO")) == "" then userok("No prior progress note found.")
elselocal a = DOCUMENT.PROGRESS_1
local b = obsprev("PROG1ADDINFO")IF (b) == "" then userok("No prior progress note found.")
else
IF (size(str(a) + HRET + str(b))) >1999 then
return userok("The prior progress note is too large and cannot be added to this field.")
else
IF useryesno("Prior progress note:\r\n\r\n" + str(b) + "\r\n\r\nClick 'Yes' to add to today's progress note; otherwise click 'No'.") == "Yes" then
a = str(a) + HRET + str(b)
else
a = aendif
endif
endif
endif
}
}
One thing I noticed when doing a MEL trace was that the function was returning "" for my A variable even when I had text entered into the edit field. I tried setting the local a to str(DOCUMENT.PROGRESS_1) but it didn't fix the issue. This is what I have in my MEL trace:
>{fn65441505421865364()}
execute>call FN65441505421865364()
execute>call PHPI_VIEW_INSERT_PRIOR1()
execute>call OBSPREV("PROG1ADDINFO")
results>"This is my test prior."
execute>"This is my test prior." == ""
results>FALSE
execute>if FALSE
results>FALSE
execute>Document.PROGRESS_1_6544_1485188615_650
results>""
A = ""
""
execute>call OBSPREV("PROG1ADDINFO")
results>"This is my test prior."
B = "This is my test prior."
results>"This is my test prior."
execute>"This is my test prior." == ""
results>FALSE
execute>if FALSE
results>FALSE
execute>call STR("")
results>""
execute>"" + "\r\n"
results>"\r\n"
execute>call STR("This is my test prior.")
results>"This is my test prior."
execute>"\r\n" + "This is my test prior."
results>"\r\nThis is my test prior."
call SIZE("\r\nThis is my test prior.")
results>39
execute>39 > 1999
results>FALSE
execute>if FALSE
results>FALSE
execute>call STR("This is my test prior.")
results>"This is my test prior."
execute>"Prior progress note:\r\n\r\n" + "This is my test prior."
results>"Prior progress note:\r\n\r\nThis is my test prior."
execute>"Prior progress note:\r\n\r\nThis is my test prior." + "\r\n\r\nClick 'Yes' to add to today's progress note; otherwise click 'No'."
results>"Prior progress note:\r\n\r\nThis is my test prior.\r\n\r\nClick 'Yes' to add to today's progress note; otherwise click 'No'."
09/21/2017 14:13:20.488 INFO Process Id #5092 ML Thread [MelTrace] execute>call USERYESNO("Prior progress note:\r\n\r\nThis is my test prior.\r\n\r\nClick 'Yes' to add to today's progress note; otherwise click 'No'.")
results>"Yes"
execute>"Yes" == "Yes"
results>TRUE
execute>if TRUE
results>TRUE
execute>call STR("")
results>""
execute>"" + "\r\n"
results>"\r\n"
execute>call STR("This is my test prior.")
results>"This is my test prior."
execute>"This is my test prior."
results>"\r\nThis is my test prior."
execute>A = "\r\nThis is my test prior."
results>"\r\nThis is my test prior."
results>return "\r\nThis is my test prior."
results>return "\r\nThis is my test prior."
execute>end
results>"\r\nThis is my test prior."
Any ideas where I'm going wrong with this?
I don't see the function returning anything.
You either want to add
document.progress_1 = a
to the end of your function or
return a
and have a button call this function with the value returning into document.progress_1
This should fix it, unless I am missing something.
-James
Whoops! Of course it was something this easy. I guess I missed the forest for the trees trying to get all my endifs in line or something. Thank you!