Skip to main content

Problem Statement: Lookup columns on the Nintex forms are displaying Loading message and never loads for the user to select when a custom Javascript is added on the form Description: We have certain fields on the form which will enabled/disabled based on the user and status [ field from another list] Example: Project Number field will be enabled only if the logged in user is Admin and Coversheet Status[ which comes from “Coversheet” list] is “Approved” We are using rest api and JSOM to query the list and disable .Javascript is working fine but when the form opens in edit mode, all look up fields are displaying as “Loading”… as shown in the screen

 

var pollSP;

var CoversheetId;

var appweburl;

var hostweburl;

NWF.FormFiller.Events.RegisterAfterReady(function () {

  

    pollSP = setInterval(checkSPLoad, 500);

  

});

 

function checkSPLoad() {

    if (clientContext) {

        window.clearInterval(pollSP);

        hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));

        appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));

        var layoutsPath = "/_layouts/15/";

        var scriptbase = appweburl + layoutsPath;

 

        NWF$.getScript(scriptbase + "SP.js",

            function ()

            {

                NWF$.getScript(scriptbase + "SP.RequestExecutor.js", onSPLoad);

            }

        );

      

    }

}

 

function onSPLoad() {

    var spGroups = clientContext.get_web().get_currentUser().get_groups();

    clientContext.load(spGroups);

    clientContext.executeQueryAsync(

        Function.createDelegate(this, function () { OnSuccess(spGroups); }),

        Function.createDelegate(this, this.failed)

    );

}

function getQueryStringParameter(paramToRetrieve) {

    var params =

        document.URL.split("?")01].split("&");

    var strParams = "";

    for (var i = 0; i < params.length; i = i + 1) {

        var singleParam = params.split("=");

        if (singleParams0] == paramToRetrieve)

            return singleParam 1];

    }

}

 

 

 

 

 

 

function OnSuccess(spGroups) {

    try {

        var groupsEnumerator = spGroups.getEnumerator();

        while (groupsEnumerator.moveNext()) {

            var userGroupNames;

            var currentGroup = groupsEnumerator.get_current();

            userGroupNames += currentGroup.get_title() + " ";

            if (currentGroup.get_title() == "PAAdmin") {

               // var ID = decodeURIComponent(getQueryStringParameter("ID"));

                var ID = "1";

                alert("inside PAAdmin");

     

 

                var web = clientContext.get_web();

 

                //Geting reference to the list

 

                var olist = web.get_lists().getByTitle('Projects');

 

                var oitem = olist.getItemById(1);

 

                //get Title,id,ConfigItem fields

 

                clientContext.load(oitem, "Title", "Id", "Coversheet");

 

                clientContext.executeQueryAsync(function () {

 

 

 

                    var columnFieldValue = oitem.get_item("Coversheet");

                //    alert(columnFieldValue);

                    var lookupValue = columnFieldValue.get_lookupValue();

                    alert(lookupValue);

                    var lookupId = columnFieldValue.get_lookupId();

                    alert(lookupId);

                    var executor = new SP.RequestExecutor(appweburl);

                    alert(appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('Coversheet')/items?@target='" + hostweburl + "'" + "&$select=CoverSheet_x0020_Status,Title,Id&$filter=Id eq '" + lookupId + "'");

                    if (lookupId != null) {

 

                      

                        executor.executeAsync({

 

                            url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('Coversheet')/items?@target='" + hostweburl + "'" + "&$select=CoverSheet_x0020_Status,Title,Id&$filter=Id eq '" + lookupId + "'",

                            method: "GET",

                            headers: { "Accept": "application/json; odata=verbose" },

                            success: function (data) {

                                alert("success");

                                var result = JSON.parse(data.body).d.results;

                                for (var i = 0; i < result.length; i++) {

                                    var Coversheetstatus = result.CoverSheet_x0020_Status;

                                    alert(Coversheetstatus);

                                    if (Coversheetstatus == "Approved") {

                                        NWF$('#' + PrjNo).prop("disabled", false);

                                        NWF$('#' + PrjNo).attr("disabled", false);

                                    }

                                }

 

                                },

 

                            });

                    }

 

                },

                    function (a, b) {

 

                    alert(b.get_message());

 

                });

             

           

              

            

           

 

         

            }

        }

    } catch (err) { alert(err); }

}

 

function onQueryFailed1(sender, args) {

    alert('Request failed. Error: ' + args.get_message() + ' StackTrace: ' + args.get_stackTrace());

}

function OnFail() {

    alert("Failed to load groups")

}

can you maybe show us your js code?


Thank u..I have pasted the code with the problem statement.

Please have a look


Is the issue is resolved We Also facing the Same issue?


Reply