Hello Everyone,
Thanks for reading my question.
I've created a Field of type File and place it on the form. I need to do basic validation of the file such as File extension and File content. Now, with the help of Dataverse REST Builder I've the code to find the file name/extension & file content but the challenge is if I run the code on the fieldOnChange then the needed information doesn't exist in the database by the time. So, I need to find some other event on which I can trigger the code.
this.fileToProcessOnChange = function(executionContext){ prg_DataTransfer.checkFileExtension(executionContext); } this.checkFileExtension = function (executionContext){ $.ajax({ type: "GET", url: Xrm.Utility.getGlobalContext().getClientUrl() "/api/data/v9.2/prg_temporarydatas(cfb732f7-7acd-4193-9bfc-d4b352669f1c)?$select=prg_filetoprocess_name", headers: { "OData-MaxVersion": "4.0", "OData-Version": "4.0", "Content-Type": "application/json; charset=utf-8", "Accept": "application/json", "Prefer": "odata.include-annotations=*" }, async: true, success: function (data, textStatus, xhr) { var result = data; //console.log(result); // Columns var prg_temporarydataid = result["prg_temporarydataid"]; // Guid var prg_filetoprocess_name = result["prg_filetoprocess_name"]; // Text console.log("File Name: " prg_filetoprocess_name); }, error: function (xhr, textStatus, errorThrown) { console.log(xhr); } }); }
Hello,
You can try below code to get the file Name using client api on onSave event-
formContext.getAttribute("cr127_filecolumn").fileName;
Thanks Bipin for the workaround. Because of some unforeseen challenges we're not allowed to create any plugin or custom workflow. Having said that I appreciate your reply.
Hello,
You can write plugin on Post Create/Update to do the same validation and throw an error when validation failed.
MikeC282 - Thanks for the reply mate.
Do you mind explaining it further? If I understand you correctly you mean:
With above steps it wouldn't guarantee the needed information doesn't exist in the database by the time. Please let me know your thoughts!
Hey bud,
Could you not just force a save on the record before running the REST API to check for file name and extension? That way it'll exist?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156