Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Client-side: Need to check the file name & extension of Field Type = Field

$
0
0

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);
        }
    });
}

Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>