I have been struggling with this all afternoon. Very simple situation
If the user presses a button we need to add a form to the update and then open it to a certain tab.
I use the run_process option (you would think that buttons would allow an add button and open together for a connection type
The code is like this
ADD_FORM_COMP('Enterprise\Mental Health','Depression/IPV/Fall Risk','AFTER_CURRENT','OPEN')
OPEN_FORM_COMP('Enterprise\Mental Health\Depression/IPV/Fall Risk','Intimate Partner Violence')
When the hutton is clicked and the form isn't yet loaded, it successfully loads it but then gives the following error
Cannot open form component Depression/IPV/Fall Risk, that is not in the chart. Please insert the component first
It's like the open happens too quyickly for the program to realize that the form has been added.
If I insert a dialog box with userok after the add_form_comp and before the open_form_comp, the problem is solved, but this requires an extra click by the users, and the whole point of not loading the form in the first place is to avoid unnecessary clicks. I got sophisticated as follows:
if (match(GET_FORM_LIST(),"Depression/IPV/Fall Risk")<=0) then
ADD_FORM_COMP("Enterprise\Mental Health","Depression/IPV/Fall Risk","AFTER_CURRENT")
userok("Adding Depression/IPV/Fall Risk Form")
else
""
endif
OPEN_FORM_COMP("Enterprise\Mental Health\Depression/IPV/Fall Risk","Intimate Partner Violence")
At least in this way it only gives the popup alert when the form is actually added
Somebody must surely have encountered this? I tried to just insert garbage code but that didn't help. ASny other workarounds/fixes?
Thanks!
Ken
I use an IF statement to test for the existence of the form.
I've had good luck with this:
{
if (match(GET_FORM_LIST(),1,"BH Counseling Referral Screen") >0 ) then
OPEN_FORM_COMP("Enterprise\Psy\BH\BH Counseling Referral Screen", "")
else
ADD_FORM_COMP("Enterprise\Psy\BH", "BH Counseling Referral Screen", "AT_END", "OPEN")
endif
}
And if you still have timing issues with Sandy Jo's code, you could put a loop in where you use a match on the form name from GET_FORM_LIST and when it finds it, do your open. Set the loop count to something like 5 or 10.
that's pretty much what I'm doing except I need to do the open form also as the user wants it to jump to a sopecific tab whuich you can't do with add. The form has been added, but it needs a delay before it can be opened and jump to the tab. I tried using jump_to_tab after adding the form but it says there is no such tab in the "dialog" box
that seems like it might work...I'll give it a try..thank you!
nope, didn't work, I even had a loop going to 100,000. There was a lag but still thought the form wasn't loaded Of course when I print out the value of the loop counter everything works. I could make it an infinite loop but am wary of the consequences, and I suspect it would never work. It seems like displaying an alert does some sort of synch. Is there any other function that might do that less obtrusively?
As I said, if I didn't have to jump to a particular tab this wouldn't be a problem because could either do a add or an open depending if the form exists. It's having to do an add and then an open (or a jump to tab) that is apparently an egregious demand 🙂