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?
Question_answer keyword
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.
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]"
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.
%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.