Hi All,
You all helped me last time with coding to add a form if a question was answered a certain way. It works, but the issue I'm having is the form keeps appearing before the form I am on when answering.
So If I'm on form A and I click yes to a question, Form B automatically pops up on the left nav (yay!), but Form B appears at the top, before the Form A I am on, so if I don't catch it and I continue down and click next I'm missing an entire form.
My code to add it is this:
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity of Ideation","AFTER_CURRENT")
It SHOULD appear after current like it states, but maybe I got the syntax wrong? Please help!
From some testing, I found that the ADD_FORM_COMP code does not look at what form is currently open, but where the focus is on the left nav bar. I added a button to a form that uses the ADD_FORM_COMP code and it worked correctly most of the time. But if I right-clicked on a different form on the left nav bar and removed it, the right side of my screen stilled showed form A, but clicking the button would place form B after the spot where I had deleted a form. (weird huh?)
Could you give us some further info on what your form does to decide to open the form, and what else is in the left nav bar at the time? are there many other forms, or just form A, and then B? Also, which version of CPS are you on? I know an older version had an issue with the AFTER_CURRENT Symbol.
Hey so that is some good information. I'm using VFE 6.00, Centricity 12.0.7
There are 3 other pages, but the code is on the first. So I bring up the form with 4 pages total, on the first page I click 'Yes' to a radio question which triggers my code to bring up this form, if I change the answer to 'No' it removes the form.
This functionality works, its just the form keeps going to the top of the list instead of after the first page where I'm clicking the 'Yes'.
The exact code is this:
{
if OBSNOW("CSSRS1SinceLast") = "Yes" or
OBSNOW("CSSRS2SinceLast") = "Yes" then
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity Last Visit","AFTER_CURRENT","","")
else if OBSNOW("CSSRS1SinceLast") == "No"
then
REMOVE_FORM_COMP("C-SSRS Intensity Last Visit")
else
""
endif
endif
}
it seems like if I do at_end it works, and if I right click to select other forms then it'll place it'self after the first, but even when selecting the first it still places it before it. Hmmmm is there a way to select a form through code so when it comes up another page is selected and it can just insert it there. Anything is better than the beginning because users will not realize to go backward to complete it.
Hi again. Thank you for posting the code. I think the reason AFTER_CURRENT is not working is due to your CPS version, as I cannot get the code you sent to fail on my CPS12.2.2. However, I have a code solution like you requested. ^_^
Here is a modified version of your code. You will have to type the name of the form that this code lives in for thisFormName = "MEL Tester", but everything else should run as is:
{
if OBSNOW("CSSRS1SinceLast") == "Yes" or
OBSNOW("CSSRS2SinceLast") == "Yes" then
local formsArray = getfield(GET_FORM_LIST(),"|","")
local thisFormName = "MEL Tester"
local newFormNumber = "1"
for c = 1, c <= size(formsArray),c= c+1 do
if match(formsArray[c],thisFormName) > 0 then
newFormNumber = c+1
endif
endfor
userok(str(newFormNumber))
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity Last Visit",str(newFormNumber),"","")
else if OBSNOW("CSSRS1SinceLast") == "No"
then
REMOVE_FORM_COMP("C-SSRS Intensity Last Visit")
else
""
endif
endif
}
This will pull in the list of all forms on the left, and use the variable thisFormName to find the position where your form is located. then it puts the C-SSRS form 1 position after that.
Please let me know if you have any issues getting this to work.
Thank you,
Daniel C
Thank you!!!!! That works, I also found what was going on. I had a hidden text form for printing a cover sheet so it was adding the form under that text sheet that was hidden so it looked like it was above where I was answer the question, but that's because the system was not recognizing I was on that page, but instead when it first opens it thinks I'm on that hidden text document page instead, thus this form was being added after -_-
I appreciate the help! It is not working 🙂
That is great news! ah, the wonders of MEL code continue to amaze/baffle me. 🙂
Have a happy Friday!
I know there was a version where GE broke the functionality of ADD_FORM_COMP. It may be in your version of Centricity. I think we ended up using ADD_FORM_COMP with the number indicating where in the update the form should be. I believe it was fixed in either a service pack or later version of Centricity. Also, you are 3 versions behind in Visual Form Editor. You can go to www.logical-innovations.com, log in, and download the latest version and upgrade for free if your license is still valid.
Good Luck!