Hi Everyone,
You guys helped me write the code to have a form on the left show up if certain rules are met and hide it if the rules go away. It worked great, but I found there was an error if the rules to hide the form are met before the form shows up so I tried to add a check to only remove it if it exists AND the rule is met but now I'm getting a problem where the form keeps going on off on off on off infinitely, thus sending the software into spam freezing issues of the form hiding and unhiding. Please help!!
Here is my code:
{
if OBSNOW("CSSRSDeadWishLFT") = "Yes" AND (match(GET_FORM_LIST(),1,"C-SSRS Intensity of Ideation") == 0) or
OBSNOW("CSSRS1PastMonth") = "Yes" AND (match(GET_FORM_LIST(),1,"C-SSRS Intensity of Ideation") == 0) or
OBSNOW("CSSRS2LFT") = "Yes" AND (match(GET_FORM_LIST(),1,"C-SSRS Intensity of Ideation") == 0) or
OBSNOW("CSSRS2PastMonth") = "Yes" AND (match(GET_FORM_LIST(),1,"C-SSRS Intensity of Ideation") == 0) then
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity of Ideation","AFTER_CURRENT","","")
else if OBSNOW("CSSRSDeadWishLFT") == "No" AND (match(GET_FORM_LIST(),0,"C-SSRS Intensity of Ideation") > 0)
then
REMOVE_FORM_COMP("C-SSRS Intensity of Ideation")
else
""
endif
endif
}
First thing that jumps out to me is that you have a single equals sign in front of all of the "Yes" values instead of the double equal signs. Can you fix this and try it to see if it is fixed or if we need to dig further?
Hey, so I may need to just start over as I'm not sure if the problem is pinpointed in the above post. This code below works perfectly for what I'm trying to do; however if I bring up the screen for the first time and click 'no' for the answer CSSRSDeadWishLFT it gives me an error, but if I click Yes and then back to no then I get no error. The functionality of the form coming up and then going away works fine, its only if I click no initially i'll have the issue of the error giving me an error because it cannot remove a form that is not there.
{
if OBSNOW("CSSRSDeadWishLFT") = "Yes" or
OBSNOW("CSSRS1PastMonth") = "Yes" or
OBSNOW("CSSRS2LFT") = "Yes" or
OBSNOW("CSSRS2PastMonth") = "Yes" then
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity of Ideation","AFTER_CURRENT","","")
else if OBSNOW("CSSRSDeadWishLFT") == "No"
then
REMOVE_FORM_COMP("C-SSRS Intensity of Ideation")
else
""
endif
endif
}
OK, what about the trying the following inside your statement?
else if OBSNOW("CSSRSDeadWishLFT") == "No"
then ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity of Ideation","AFTER_CURRENT","","")
REMOVE_FORM_COMP("C-SSRS Intensity of Ideation")
else ""
If the Form already exists then it should just jump to it then remove it. If it doesn't exist then it adds it and then removes it.
I think you should also make your equals to be in the proper syntax. Just because they are working now, doesn't mean that they will continue to as KB Updates and Version Upgrades occur.
Hey,
Here is the new code and while it works it keeps flashing the form up and then it goes away (which is the intention) but the end users will absolutely see that and complain, any other solutions to just add a check to say if its not there don't do anything and if its there and ==no then remove it?
{
if OBSNOW("CSSRSDeadWishLFT") == "Yes" or
OBSNOW("CSSRS1PastMonth") == "Yes" or
OBSNOW("CSSRS2LFT") == "Yes" or
OBSNOW("CSSRS2PastMonth") == "Yes" then
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity of Ideation","AFTER_CURRENT","","")
else if OBSNOW("CSSRSDeadWishLFT") == "No"
then
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity of Ideation","AFTER_CURRENT","","")
REMOVE_FORM_COMP("C-SSRS Intensity of Ideation")
else
""
endif
endif
}
Finally got it working; posting it in case others have the same issue. Here is the final code that works:
{
if OBSNOW("CSSRSDeadWishLFT") == "Yes" or
OBSNOW("CSSRS1PastMonth") == "Yes" or
OBSNOW("CSSRS2LFT") == "Yes" or
OBSNOW("CSSRS2PastMonth") == "Yes" then
ADD_FORM_COMP("Enterprise\Fusion\Juvenile","C-SSRS Intensity of Ideation","AFTER_CURRENT","","")
else if OBSNOW("CSSRSDeadWishLFT") == "No"
then
if (match(GET_FORM_LIST(),1,"C-SSRS Intensity of Ideation") > 0) then
REMOVE_FORM_COMP("C-SSRS Intensity of Ideation")
else ""
endif
else
""
endif
endif
}
Thanks!