Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Remaining Information after populating data in a list box

Avatar

Level 3

Hi Guys,

I have a small problem. Actually  I thought everything works perfect but as i saved or sent the form and opened it again the populated information was gone. I was shocked.

I give you short function of my form.

I type in texfield "Type" "a" or "b" a dropdown list with A, B, C appears. If I select A ,B or C or all of them then this information appears in a list box. that's perfect so far, but when I save this pdf file or send it to someone and open it, then the selected information is gone. this is horrible!

Does anyone know what's going on wrong??

I think the information should remain otherwise the function doesnt make sense.

I appreciate it a lot if someone can help me to solve this problem!

Thanks in advance!

Diana

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You are chganging the state of the form in script. When you save it those changes are not being saved because your code does not do that. You can have the form save those changes for you so you do not have to worry about it. This is controlled in the File/Form Properties menu. Choose the Defaults tab and change the "Preserve scripting changes" radio button to Automatically then try it again (see the image below).

Paul

Capture.GIF

View solution in original post

18 Replies

Avatar

Correct answer by
Former Community Member

You are chganging the state of the form in script. When you save it those changes are not being saved because your code does not do that. You can have the form save those changes for you so you do not have to worry about it. This is controlled in the File/Form Properties menu. Choose the Defaults tab and change the "Preserve scripting changes" radio button to Automatically then try it again (see the image below).

Paul

Capture.GIF

Avatar

Level 3

Thank you so much!!!!

It works, I cant believe:))

Diana

Avatar

Level 3

Hey Paul,

i have just one another question concerning the same form.

i want to populate the information from the first listbox to another listbox with this code :

Com1.addItem(xfa.event.newText)

;

and it populates, but only if i click on the items from the first listbox.

do you know why it's happening?

Thanks in advance!

Diana

Avatar

Former Community Member

You have the code on the change event. The change event is fired when the user selects something

in the list box and "changes" the value. When  do you want to add the item to the 2nd list box?

Paul

Avatar

Level 3

Well, the second listbox will be on another form and should be filled in when the first form has been already filled and sent back. Unfortunately I cant directly fill my selection from the dropdown list into both listboxes.

I tried this code in exit, but it doesnt populate at all.

Thanks for ur answer!

Diana

Avatar

Former Community Member

You can assign the xfa.event.newText to a variable then you can reuse the var as required and you can set each of the listboxes according. The code would look something like this:

var ListBoxSelection = xfa.event.newText;

Com.addItem(ListBoxSelection);

Com1.addItem(ListBoxSelection);

Or I have completly misunderstood why you cannot set both ListBoxes.

paul

Avatar

Level 3

The reason why I cant populate the information from the dropdown list in 2 list boxes simultaneously, is because the second list will be on a second form. and only if i push a button create the second form the information from the first list box should be populated in the second listbox.

the reason is, that different people will select items from the dropdown list and populate it in the first listbox. after gathering these information they should appear in a new form in the second listbox.

I hope didnt explain it confusing

Thanks,

Diana

Avatar

Former Community Member

So you cannot push information from one form to another via script. The only way you

will be able to get close is if you export the data then import to the new form.

Make sense?

Paul

Avatar

Level 3

Paul, thank you in advance for all your help. It does make sense, and following your tip, I tried using the Distribute Form in LiveCycle, but the problem is that the dataset for some reason does not display the values contained in the listbox. The listbox does retain the information after save (thx to your answer) but I don't see it in the dataset file, any ideas?

Thank you again,

Diana

Avatar

Former Community Member

The data file will only contain the value that the user selected .....it does not make sense to carry along everything else

(in a data file). Maybe you shodul use an alternate method of capturing that information. What about a field that will repeat for each entry that you want?

Paul

Avatar

Level 3

Paul, there's only one issue. The idea behind the listbox is to capture the different selections from another dropbox in the form. However, there are over 40 different values in the dropdown, so the listbox may end up with 10 or 15 of those values - these are the values I want to be able to save in the dataset. I don't know what will be the best way to do this, any ideas?

Thank you,

Diana

Avatar

Former Community Member

What if you put the selected values in a dynamic table. Each selection would add a row to the table and each item in the table woudl be a unique object hence the values woudl be transported in the dataset.

Paul

Avatar

Former Community Member

Here is an updatetd sample to give you the idea of what I am talking about. You can hit the save data button to see what the submitted data woudl look like.

Paul

Avatar

Level 3

Paul, this is what I needed, thank you very much for all your help, one last question though, if I want to delete one of the items from both the listbox and the dynamically created cell in the table, how would I do it?  

Avatar

Level 3

Paul, this works but what I would like to do is make the table cells (the text dynamically created) invisible, so the user would not have the second box, both items should be deleted using the remove botton. Somewhat like:

var

x = Com.selectedIndex;

Com.deleteItem(x);

Table_SF._Repeat_SF.removeInstance(x);

this code doesn't work, but hopefully with your help, we could make work

Avatar

Former Community Member

I think this is what you asked for ......you will also have to check to make sure that the user picked something in the DDlist before deleting

Paul

Avatar

Level 3

Paul, thanks a lot for so much help!!!

it works brilliant

Diana

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----