I have a form with some text and other fields. There is a select box on the form that is populated with an array of country objects.
[
{"countryname":"United States”, countrynamecode:”USA”,”Countrytelcode”:”+1”,”label”: “United States +1”}…….etc…
]
The user fills out the form and makes a selection from the select box as part of the form.
The user then clicks a “Validate” Button that executes a function to check the form over and return any error message if it is not complete, or “OK” if all good.
Problem: When the user clicks the Validate Button all works as expected. I even added a test text component that displays : selectedcountry.label.
After the function is run the test text field still properly displays the previously selected country object’s label just fine, HOWEVER, the select box with $This.label as its text to display, no longer shows the previously selected label. It looks like it retains the previously selected object as the selected country, but it just no longer shows anything in the select box?? Any advice welcomed…wierd…Thx!
Are you perhaps clearing the selected country object right afterward, like you’re doing with your other inputs? Or maybe you’re calling a standard action on the select box’s selected element that resets or interferes with the display? Or doing any other treatments on that selected item?
Thx for the reply. I’m soo close to having the account opening process ready, but just a few sticky issues left…Oddly, the data only disappears from the select label in the Select Box the first time I run the validate function. Any subsequent selections and revalidations seem to be retained in the selectbox text display just fine..? So– page loads initially, form is filled out, select box selection made, select box label changes and displays just fine. Validate function is clicked, validation goes fine and text is displayed at bottom of form with validation response. $This.label text in the select disappears?? I reselect country, run validation again, label is retained just fine on the subsequent validations.
Note 1: When I click the validate button it simply sends data from the form to the validate function as parameters and returns a string msg.
Note 2: I have another similar object, that retains selecred item label text just fine. So maybe something about this particular array?
No other functions or actions are attached to the Validate Button.
This is really wierd…I’ll keep at it, but head scratcher..
One additional note: For the similar component that works fine on the form, the selected item qodlysource is an object attribute of a namespace shared entity. Whereas the problematic component’s selected Item is simply a namespace shared object with initial value set to {}.
Thanks so much for this help. The selected element country Object is passed to the validate function.
Note: the other select box I thought worked does have the exact same issue.
-No onchange actions associated with changing the country object.
Select Box:
Datasource: countries array (of objects) (namespace)
Selected Element: country object (same namespace)
The options list of objects is loaded fine into the select box on initital page load and works fine throughout.
The text that appears in the select box for the selected country Element: $This.label is the challenge.
When i make the inital country selection all works fine and $This.label shows correctly for the selected country.
Then, when I click the validate button, the country Object is passed to the validate function as one of the parameters.
Once the function finishes and the error or ok msg appears on the form, the $This.label text disappears and the placeholder text shows again on the select.
Note 1: It seems that the country object is still correctly retaining values. If I put a text compnent on page with county.label, it still shows fine after validate.
Note 2: If I then reselect country in the select box and rerun the vaidate function– on the subsequent tries $this.label is updated and displayed just fine??
Its just the FIRST time the function is run after the form is loaded that it clears the $This.label.
Th Function. No other actions associated with the Validate Button. For simplicity I used countries but the objects are actually country telcode objects that have country name, country 3 charcter code, couty telcode, and label (i use to populate the select box $This.label)
One of the things I’ve noticed developing in qodly is there are some nuances about using array datasources on forms and some limits, ie arrayofobjectsqodlysource[5].label etc has some challenges to use on form. but outside of something related to that, this is a headscratcher..
Thanks again for the extra details. I wasn’t able to reproduce the issue on my end using a similar structure.
Could you, if possible, give me access to your project so that I can take a closer look?
Normally, if nothing is affecting the selected element, (no standard actions, no object replacement, no functions…), then whether it’s an **entity ** or just a plain object, it really shouldn’t be cleared unless something triggers it directly..
If you’d like to keep the troubleshooting work you’ve done so far, you can duplicate that page first. That way, you can safely revert the original page to its initial state, without losing any of your current progress.
Also, please check your inbox, I’ve sent you a message with my email address and the steps to add me to your project.