Unexpected result from select list


(Mahearnpad) #1

Good morning (or evening), depending on your timezone.

 

In my custom form, it appears that it's the "text" of the select list rather than the value, that's getting sent in the POST request. At least it seems that when I get the value of %response_241279_q5% (which is a select list), it's the text, not the value of the input.

 

My select list needs to hold assetIds as values, but present a friendlier form (e.g. Topic 1) as the text of the option element.  But because the value is not being used in the form submit, then this is not possible.

 

Here's what my select list looks like:

 

Options

12345  topic 1    down_arrow.png  23456  topic 2    up_arrow.png down_arrow.png 
34567  topic 3    up_arrow.png down_arrow.png
 

Assuming values on lhs, and option text on rhs.  I'm using this as the input data for a SOAP call on the form submission, where the "value" chosen in the list, becomes the "Parent ID" of an asset to be created via the CreateAsset method.  When I replicate the values on the left into the right column (above), then it works.  But this is not appropriate because the user doesn't know what an assetid is - they need to be able to see "topic 1".

 

Is this a bug?  Am I doing something wrong?


(Bart Banda) #2

Could you use the %question_answer_key_X_qY% keyword to extract that value? 

 

 

This will show the raw value for the response the user submitted for the question. X is the assetid of the Section the question has been added to or the asset ID of the Form Contents asset if the question does not belong to a section; qY is the ID of the question, for example, %question_answer_key_89_q1% (for questions 89:q1).

 

See http://manuals.matrix.squizsuite.net/keyword-replacements/chapters/custom-form for more info.


(Mahearnpad) #3

I don't think that keyword is available from the submissions actions screen - get this exception: MySource Notice

			<p>[ASSERT EXCEPTION] [string] "%question_answer_key_241279_q5%" is not a valid asset ID [SYS0320]

(Bart Banda) #4

What about if you try: %response_241279_q5_raw%


(Mahearnpad) #5

Yep, tried that too, and it's also throwing an exception similar to the last one. Seems that we're running out of options?  If I can't find a solution to this seemlngly simple problem, then I'll need to rethink the solution ;(


(Bart Banda) #6

That's strange... What version are you on?

 

A workaround to test would be to create a text field with the default value of %response_241279_q5_raw% and then use the response of the text field as the value in the soap call. 


(Mahearnpad) #7

Version 4.12.3

 

Thanks Bart. I'll try your solution - seems strange, but this might have to be the workaround (even though we shouldn't need a workaround).


(Mahearnpad) #8

Just confirming the issue:

 

This works (because the assetid is in the text between the option tags:

<select name="q241279:q5" id="q241279_q5" class="sq-form-field">

<option value="241288">241288</option>

<option value="241289" selected="selected">241289</option>

<option value="241611">241611</option>

</select>

 

This doesn't work (for the opposite reason (but this one is what we need, because it's human readable):

<select name="q241279:q5" id="q241279_q5" class="sq-form-field">

<option value="241288">Topic 1</option>

<option value="241289" selected="selected">Topic 2</option>

<option value="241611">Topic 3</option>

</select>

 

Can you or someone else in Squiz please investigate whether this is a bug?  It should be getting the value attribute value, not the text.

 

thanks


(Anthony) #9

I had a similar problem last year and got very confused with the different keyword formats that returned the same data depending on which screen you were on! At the time I'm not sure they were all documented, but Bart helped me out and and after my post I think the manuals got updated.

 

I can certainly confirm that %response_18705_q1_raw% definitely works as you'd expect in the body sections of the email options screens. So like you I would really expect it to be consistent in the submission actions area... so its either a bug or that bit of functionality jsut got missed somehow. I might well need it one day so put me down as a +1 to get it addressed in some future release!


(Mahearnpad) #10

@Anthony. keyword "availability" aside, my problem now, and this is backed up by the manual (if you look at the section of the custom forms chapter, on select list), is that although it stores a "key" and "value" pair, it quite clearly doesn't work the way the manual says it does, The key is redundant as far as I can see.  It will display the value rather than the key in the text between the <option> tags, and pass the same along in the form post.  The end result of this, is that if the values you want to send in the post are assetids, then your assetids will also be displayed in the select list (rather than a human-readable version, such as asset name etc).


(Bart Banda) #11

I've tested this on the latest version of Matrix and can confirm that the %response_208_q9_raw% works in the form submission actions screen, at least when you do a set session variable action.

 

Either this has been fixed in later versions or it is faulty with the SOAP call action. 

 

As a test, can you test on your version with the Set Session Var Form Action and see if it works there? 


(Mahearnpad) #12

@Bart

I can confirm that %response_241279_q5_raw% is working as you suggest. Because there's no mechanism for changing the position of the form submission actions, I'll have to delete everything and start again, with the Set Session Var Form Action in the first position, so I can then pass the variable into the first SOAP call. I'll do this and let you know if it's worked. Thanks for your suggestion.