AnsweredAssumed Answered

Populate choice control nintex forms

Question asked by zik500 on Apr 29, 2015

Hi ,

 

I work on a project that need to query external data and put this data automatically in drop down control (Nintex Forms) for this i use javascript code excel rest API . So i can display external data in dropdown but when i selected a value of the dropdown
and validate my form i have this error : https://community.nintex.com/thread/2395 .

 

This is my code JS to retrieve data from excel celle :

 

(function ($) {
    $.fn.fillFromExcelCell = function (srcFilePath, srcCellName) {
        var webServiceUrl = _spPageContextInfo.webAbsoluteUrl + "/_vti_bin/ExcelRest.aspx/" + srcFilePath + "/Model/Ranges('" + srcCellName + "')?$format=json";
        var xslQuery = function (result) {
            NWF$.ajax({
                type: "GET",
                headers: { "Accept": "application/json; odata=verbose" },
                dataType: "json",
                url: webServiceUrl,
                success: function (data) {
                    console.log("Info: Getting value: in progess...");
     for(var i=0;i<data.rows.length;i++)
     {
      result(data.rows[i][0].v);
     }
    
                    console.log("Info: Getting value '" + data.rows[i][0].v + "': success (" + $(this) + ")");
    
                },
                error: function (xhr, msg, e) {
                    console.log("Error: Getting value from cell '" + srcCellName + "' failed");
                }
            });
  
   
        }
         return this.each(function () {
            var $this = $(this);
            xslQuery(function {
                if ($this.is("input") || $this.is("textarea")) {
                    $this.val(i);
                }
                else if ($this.has("div[role=textbox]").length > 0) {
                    $this.find("div[role=textbox]").first().html("<p>" + i + "</p>");
                }
                else if ($this.has("input").length > 0 || $this.has("textarea").length > 0) {
                    $this.find("input, textarea").first().val(i);
                }
    else if ($this.is("select")) {
    
                    $this.append("<option value='"+i+"'>"+i+"</option>");
    
                }
                else {
                    $this.html(i);
                }
            });
        });
    };
})(NWF$);

 

and in Nintex choice control i call function to display data :

 

NWF$(".Category").fillFromExcelCell("/Style%20Library/test.xlsx","test");

Outcomes