Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
DarwinSimon
Contributor
Contributor

SelectValues() doesn't work with pre built string variable

I'm relatively new to Qlik Sense and the world of mashups, but I haven't been able to find any similar questions on the community. 

I'm currently building a mashup and I've created a List, used the callback function to fill a form with checkbox inputs, and added a submit button. 

What I'm struggling with is getting SelectValues() to work with a string variable that combs the form for selections and puts them in the correct format. 

$("#form-member-status .submit-button").click(function() {
			let myForm = document.getElementById("form-member-status").querySelectorAll('input[type=checkbox]');
			var selections = [];
			for(var i=0; i<myForm.length; i++) {                    
                    if(myForm[i].checked) {
						selections.push('"' + myForm[i].value + '"');
					} 
            };
			var selectionsString = '[{qText: ' + selections.join("},{qText: ") + '}]';
			app.field("StatusOfMember").selectValues(selectionString, false, false);
		});

For some reason this does not work. However, if I add in alert(seletionsString) and take that value and paste it in so I have the following, this works fine.

app.field("StatusOfMember").selectValues([{qText: "Member"},{qText: "Partner"}], false, false);

This shows the rest of the code is working correctly. 

Any help would be much appreciated.

Labels (3)
1 Reply
ajaykakkar93
Specialist III
Specialist III

hi, can you console seletionsString & give a example how it comes 

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting