urgent
survey definition :
JSON{ "title": "File upload", "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "panel", "name": "panel1", "elements": [ { "type": "text", "name": "uhid", "title": "Patient ID ", "isRequired": true }, { "type": "text", "name": "patient_name", "startWithNewLine": false, "title": "Initials", "description": "Enter the patient initials or first few letters of the name", "isRequired": true }, { "type": "text", "name": "age", "startWithNewLine": false, "title": "Age (years)", "description": "Please enter a whole number.", "isRequired": true, "inputType": "number" }, { "type": "radiogroup", "name": "gender", "startWithNewLine": false, "title": "Gender", "description": "Please select one.", "isRequired": true, "choices": [ { "value": "item1", "text": "Male" }, { "value": "Item2", "text": "Female" } ] }, { "type": "radiogroup", "name": "eligibility", "visibleIf": "{uhid} notempty", "title": "Eligibility", "defaultValue": "continue", "readOnly": true, "choices": [ "continue", "terminate" ] } ], "title": "Patient Registration" } ], "title": "Patient Registration", "description": "Enter the details of the patient to be enrolled in this study. You will be able to move ahead to the main form only for eligible patients as per the inclusion criteria" }, { "name": "page2", "elements": [ { "type": "text", "name": "user" }, { "type": "file", "name": "question1", "title": "test upload", "storeDataAsText": false } ] } ], "triggers": [ { "type": "runexpression" } ], "widthMode": "responsive"}
survey data:
JSON{ "age": 34, "uhid": "multi 09 may", "gender": "item1", "pageNo": 1, "question1": [ { "name": "patient_form_data_202304262342-(553279).csv", "type": "", "content": "da1a74ea-3d6a-40de-8257-cc122daac8f3" }, { "name": "patient_form_data_202304262329-(804409).json", "type": "", "content": "b093d108-c12e-41b4-8a4c-65901c018d25" } ], "eligibility": "continue", "patient_name": "vinod", "SurveyComplete": false, "eligibilityStatus": true}
version: 1.9.86 (survey-angular-ui)
getting bellow error:
note: error is occuring when updated from version 1.9.66 to 1.9.86.
using survey.mergeData() to assign the data.
added all three event handlers, i.e. onUploadFiles, onDownloadFile, onClearFiles.
Hello,
It is strange that you have this type of error. It means that your file item instance has content but it is not a string.
I have created a PR that should fix the issue. It will be included into next version that we will release tomorrow or after tomorrow.
Thank you,
Andrew
SurveyJS Team
as you have understood the issue, i want to explain a bit more.
after updating to the latest version, "onDownloadFile" event handler is getting "options.content" as an array of objects i.e.
[{content: string, type: string, filename: string}]. it is breaking the event handler function as it is supposed to be a string only.
Hello,
Thank you for the update.
The
options.content
value in the onDownloadFile event handler contains data which you pass from theoptions.callback
function of thesurvey.onUploadFiles
function. For instance, the following code uploads files to your server and returns a file link as acontent
property value:survey.onUploadFiles.add((survey, options) => { var formData = new FormData(); options.files.forEach((file) => { formData.append(file.name, file); }); var xhr = new XMLHttpRequest(); xhr.open( "POST", "https://api.surveyjs.io/private/Surveys/uploadTempFiles" ); xhr.onload = function () { var data = JSON.parse(xhr.responseText); options.callback( "success", options.files.map(function (file) { return { file: file, content: "https://api.surveyjs.io/private/Surveys/getTempFile?name=" + data[file.name] }; }) ); }; xhr.send(formData); });
In the

survey.onDownloadFile
callback, the options.content returns a specified link:You can run the following example and test the code: https://codesandbox.io/s/surveyjs-angular-forked-zh0tbl?file=/src/app/components/survey.component.ts:569-1327.
If you have any issues after the upgrade, please feel free to share a problematic sample so that I can run it on my side and check.
Thank you
i just used your example that that provided by codesandbox link. i just uploaded a file and copied the output from console and i am pasting the same below.
{ "files": [ { "name": "patient_form_data_202304262329.json", "type": "application/json", "content": "https://api.surveyjs.io/private/Surveys/getTempFile?name=f9dadef2-1e8e-40de-88db-a93b002db2cf.json" } ] }
then i just added "survey.mergeData()" to your example code by passing the above json then i got the error that i have provided you in the support ticket.
one more thing, i am pretty sure that i am passing string value to the content key in the options callback. i can be sure because, the same code worked until i have upgraded.
Hello,
Thank you for the update. I reproduced the issue and forwarded it to our developers for further research.
https://github.com/surveyjs/survey-library/issues/6166
Please look forward to our updates.
Hello,
I believe we have fixed this issue by this PR. The fix will be available in v1.9.87 that we are going to release tomorrow.
Thank you,
Andrew
SurveyJS Team
for testing purpose (version- 1.9.87) i just forked a project from your upload file example for angular, and here it is
https://codesandbox.io/s/surveyjs-angular-forked-h1cze3
i just added "mergeData" line at 17th line, and "console.log" at 59th line.
why it is not working?
in my local i am still facing the issue where "options.content" being an array instead of a string. and please understand that i know whatever i pass for content key in upload file event handler will come to the download file event handler's "options.content" key.
the issue is only occuring when trying to populate data with mergeData , not when uploading for the first time. and also please again note that our application worked fine until recent survey-angular-ui package upgrade (without changing single line of code).
Hello,
I am sorry, do you have error in this example? If yes, could you please provide steps to reproduce the issue? It works fine for me. Probably, I did not follow some steps.
Thank you,
Andrew
SurveyJS Team
were you able download the file?, i mean did u see any logs in console that i have placed in the download file event handler?
any updates?
we have a deployment, this issue is blocking us from doing so. could you confirm if you have considered this as an issue?
Hello,
Please accept my apologies for the delayed response. Please let me check your CodeSandbox.
Hello,
I do not get any errors with the supplied CodeSandbox. Please clarify what is the problem and how to reproduce it.
as i have explained before, i have put a "console.log" statement in the given example. Could you check with concerned person to confirm why that console.log is not running.
I'll review the sample and get back shortly.
Hello,
If I correctly understand, the issue is that the
onDownloadFile
callback is not raised when you load a survey for the first time. Therefore, no preview appears for the image which you load from code using themergeData
function. Would you please confirm this?I forwarded this issue to our developers for further research: The survey.onDownloadFile event is not raised when loading a File question content using the survey.mergeData function.
Please let me know if you have additional questions.
you got some part, and please go ahead and let me know the status.
actually i am facing another issue also, that i will explain after you are able to fix this.
OK, I'll keep you posted. Please stay tuned.
Hello,
We have fixed this issue. The fix will be available with our next maintenance update. Should you have any questions or require further assistance, please feel free to contact us at any time.
could you provide me any estimated time about when you will be able to release this?
i can see that you released a new version (1.9.88). it solved the problems i am facing. but i think a new one is introduced, that is , image previews are not coming in the servey.
Hi,
I confirm that an image preview appears correctly in v1.9.88: https://codesandbox.io/s/surveyjs-angular-forked-k607t4?file=/src/app/components/survey.component.ts.
"survey-angular-ui": "1.9.88", "survey-core": "1.9.88"
Would you please share a problematic demo for research?
that preview thing is my code issue. but now i am facing one more issue with survey-pdf. you can find the example below,
https://codesandbox.io/s/surveyjs-angular-forked-h1cze3
click on the complete after uploading document.
Hello,
Thank you for the update. As your recent issue relates to another library, I created a separate ticket on your behalf: T13152: Issue with Survey PDF Generator. We placed it in our processing queue and will process it shortly.