Question_answer keyword


(Douglas (@finnatic at @waikato)) #1

We have a custom form with a file upload, which we use to allow the user to provide an image.


%question_answer_14641_q11%



returns the not so helpful:



"filename.jpg, type image/jpeg, 121.0 KB"



Is there anyway to get the assetid for the uploaded file from a keyword or keyword modifier combination? Or do we need to nest an asset listing inside the paint layout that we use to show these?


(Charlotte Westney) #2

Hi Douglas,


Have you tried the as_asset keyword modifier?

So maybe something like this, would give you just the name of the file asset:

%question_answer_14641_q11^as_asset:asset_name%



(see explaination here)

http://manuals.matrix.squizsuite.net/keyword-replacements/chapters/keyword-modifiers



Charlie.


(Douglas (@finnatic at @waikato)) #3

Hi Charlie,


Yes - I've tried the as_asset keyword modifier. We're running 4.2.3 and using it generates a MySource Error:



"MySource Error

[ASSERT EXCEPTION] [string] "house1.jpg, type image/jpeg, 28.0 KB" is not a valid asset ID [SYS0320]"


(Mohamed Haidar) #4

That is the incorrect use of the ^as_asset modifier. It expects the original keyword value to be an asset id.
The %question_answer_X_qY% keyword grabs information out of the submission asset. The answer summary is stored in this way and currently there is no keyword to get the asset id of the created file.


(Warwick Barnes) #5
%question_answer_key_14641_q11%

…is better in that it only gives you the filename, rather than the MIME type and size as well.

 

It's a shame there's no keyword to return the asset id though. Since Matrix is already recording a "notice" link between the form submission asset and the uploaded file asset it seems that finding the asset id of the uploaded file shouldn't be a big deal.

 

Our work-around for this was to pass through the asset id of the form submission, using %list_current_asset_assetid%, to a DB Data Source which then does a query on our Matrix database: 

SELECT minorid
FROM sq_ast_lnk
WHERE majorid = %%assetid%% AND value = 'file_submission'

%ds__minorid% can then be used in an asset listing as the asset id of the uploaded file.

 

It works, but seems like a bit of a hack.


(Lewis) #6

Hey @Douglas. Not sure if this thread is still going but try %question_answer_X_qY_file_id%

You’ll need to make sure you set a Create Location in the upload form field’s Details screen.

Worked for me :slight_smile: