1 person found this helpful
Each object in the repeatiung section will have a unique name to get to it. It is not enough to have just the name of the object you must include the path to it as well. In doing so the repeating subform can have an occurance number to indicate which one you want. Note that the occurance numbers are 0 based. So to reference your field it woudl be repeating_subform[occurance number].Name.rawValue. So the selectedIndex in the DDlist will give you the occurance number that you want (but it is 1 based I think). This is also assuming that the DDList will be in the same order that the repeating subforms appear. So to get the value of the Name field your expression will be:
repeating_subform_name[DDlist.selectedIndex - 1].Name.rawValue
Thank you for the help but I seem to have trouble figuring out the best event(s) for this code. I have tried the 'change' event but since it fires on every key stroke its not the best place.
I have also tried the click event but it doesn't work like I would wish.
The drop-down may have the selection clicked or the user may enter data not in the selection list.
Would you please advise on the proper events or event to use?
I think the validate event should work well for this. I tried the following code:
if (dropdown.selectedIndex > -1) // then a selection has been made, needed because validate event is fired before a selection
textObject.rawValue = repeatingSubForm[dropdown.selectedIndex].object.rawValue; // dropdown.SelectedIndex is 0-based
However, I get the error message "repeatingSubForm[dropdown.selectedIndex] has no properties"
Any ideas? Thanks
Thanks Paul but I still have a problem...
I'm trying to use the validate event with this code: (DDlist.selectedIndex is zero-based)
if (dropdown.selectedIndex > -1) // validate is fired before a selection is made and again after
textObject.rawValue = repeatingSubform[DDlist.selectedindex].textObject.rawValue;
I get the error message "repeatingSubForm[DDlist.selectedIndex] has no properties"
Any ideas why?
I solved the "no properties" problem by using a resolveNodes on the repeatable subform before referencing its objects. The code now works as I need it BUT I get a message "validation failed"!
Do I need to set a return code or something?
Solved the error message by using
event.rc = true;
All is well! Thanks again for your help!
Typically when dealing with DDLists the exit event is the best one because that indicates that the user has finished making their selection and they are ready to move on. Most people try to use the change event but that will fire each time the user makes a selction and the rawValue will NOT be set with their selection so you have to use another means to get it. On the exit event the rawValue is set so it is much easier to deal with. You should not use the validate as that event will fire on loading the form as well as any submit operation.
Hope that helps
As it turns out in my case the validate event is perfect. I need to perform actions depending on the user either entering data or selecting from the drop-down list.
Testing the selectedIndex to be greater than -1 tells me if a selection was made or not. It allows me to skip the first validate call and only process after a selection.
Thanks again for all your help.