Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Presence Help

Avatar

Former Community Member
I know there are a lot of topics covering hiding and showing fields, subforms etc. Unfortunately none of them answer my exact issue. Hopefully someone can help.



I have a form where if someone selects a certain choice in a list box, a previously invisible field (PriorityExplanation) should appear. The value of the item in the list box that should trigger the presence variable is 4, or "High Priority".



Here is what I have on the list box's 'change' event:



if (this.rawValue == 4) {

PriorityExplanation.presence = "visible";

} else {

PriorityExplantion.presence = "invisible";

}



I have verified all the other usual suspects (e.g. form saved as dynamic). What am I missing? Help! Thanks!
9 Replies

Avatar

Level 5
Hope this is just a typo... you are missing 'a' in the else statement.

Visible/invisible/hide are valid scripts only in dynamic templates. Hope you saved your form as Dynamic form. If that is what you have, you can look in for name of the subform(s). If both the elements are separated in different subforms the expression should syntax like this...



somExpression.presence = "visible/invisible/hide";



where somExpression stands for Qualified object node reference path in the form hierarchy.



Regards,

SekharN.

Avatar

Former Community Member
That was a typo. Thanks for the catch. The form is saved as dynamic.



The list box and the 'PriorityExplantion' field (text box) are both in the same subform.



Would it help to put the text box field into its own subform?

Avatar

Level 5
Can you make sure you have defined right values under 'Binding' tab of Object pallet. Also you need to check 'Specify Item values' checkbox. I guess those item values are 0 base index if it do not let you alter the value.



Also set 'Commit on' to 'Select' under 'Field' tab of Object pallet.



if it still do not work try to use the code under 'exit' event of the list box. Also it helps having relayout statement at the end of the script. Try combination of these and let me know.

if (this.rawValue == 4) {

PriorityExplanation.presence = "visible";

} else {

PriorityExplanation.presence = "invisible";

}

xfa.layout.relayout();



SekharN

Avatar

Former Community Member
All the properties were already properly set.



I did finally get results once added the xfa.layout.relayout(); line to the script. I got the text box to appear, but only after filling in some other fields, and clicking repeatedly on ANY of the 4 items (No priority (1), Low Priority (2), Medium Priority (3), or High Priority (4).)



Once the text box appeared, I could not get it to revert to invisible again by selecting priority 1, 2 or 3. It kept jumping to High (4).



How can I:

1. Get the presence value of the text box to change back if a user changes the priority?

2. Get the text box to appear ONLY when clicking High Priority in the list box?



Also, why do I need fill out some of the other required fields on the form before this list box will react?



Really confused now, but thanks for all your help so far.

Avatar

Level 5
I am confused... is the List Box multi select? or you just have Drop-down and referring it as List Box? My understanding is you should be using Drop-down if that is what you have the code should work in both direction.

And it is more confusing when you say you need to fill out some of the other required fields on the form before list box react.

I have no clue what is happening at this time. I may be able to help you if you can email me a copy of template with more details at 'meetsekhar AT yahoo.com'.



SekharN

Avatar

Level 5
i am sorry here the right email id 'meetsekharv AT yahoo.com'



SekharN

Avatar

Former Community Member
Sekhar,



I have just sent you an email (from my Yahoo account) with the form attached. Thanks for your help.



DH

Avatar

Level 5
Hi Doug,

I looked at your form... changed the code in 'change' event to following... and it works great.



if (this.boundItem(xfa.event.change) == 4) {

PriorityExplanation.presence = "visible";

PriorityExplanation.mandatory = "error";//to set mandatory

} else {

PriorityExplanation.presence = "invisible";

PriorityExplanation.mandatory = "disabled";//to set not mandatory

}



you do not even need to use xfa.layout.relayout();



Hope this helps.

Good luck,

SekharN.

Avatar

Former Community Member
That works great!



If you don't mind, I may call on you again as this form grows more complicated.



Thanks so much for taking the time to help.