cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

Rules not applying after Nintex forms upgrade

Hi All,

Hoping someone can help. I have just upgraded our vwersion of nintex forms. We have many rules and some custom javascript on our forms. The rules stop people from being able to edit forms which have been submitted. I have not built this forms originally but since the upgrade this rule no longer works. No matter which secuirty level group (1-4) a user is in they can edit forms which have been submitted. Are there any obvious places to check? The rules are working perfectly in our dev environment where nintex has not been upgraded however, in the environment it has been upgraded all users can edit completed forms. 

 

I have made sure that all rules are still the same accross both environments. Im thinking maybe in the update some terminology has changed?

 

Please excuse some of the comments in the JS.

 

Here is the custom JS we have on one of the forms:

if (Is Display Mode)
{
var url = window.document.location.href;
   document.location.href= url.toLowerCase().replace("dispform", "editform");
}
if (Is Edit Mode)
{
//http://qualityassurance/_vti_bin/QAService.svc/UserCheck/AssociateOmbudsman/3
var svcUserCheckUrl = "/_vti_bin/QAService.svc/UserCheck/";
console.log("svcUserCheckUrl " + svcUserCheckUrl );
var listName = 'List Name';
var itemID = 'fn-GetQueryString("id")';
var serviceUri = _spPageContextInfo.webAbsoluteUrl + svcUserCheckUrl + listName + "/" + itemID ;
 console.log("serviceUri " + serviceUri);
    NWF$.ajax({
        type: "GET",
        contentType: "application/json",
        url: serviceUri,
        dataType: "json",
        success:
            function (data) {
                if (data.length>0)
                 {
                     console.log(data.length);
                     var res = data[0];
                     console.log(res);
                     if (res=='false') 
                     {
                           if (!fn-IsMemberOfGroup("QA Admins"))
                           { 
                               document.location.href=_spPageContextInfo.webAbsoluteUrl  + "/SitePages/ERROR.aspx";
                            }
                            if (fn-IsMemberOfGroup("QA Admins") && (QA Submitted==false))
                            {
                                document.location.href=_spPageContextInfo.webAbsoluteUrl  + "/SitePages/ERROR.aspx";
                            }
 
                      }
                  }
            },
        error:
            function (err) {
                alert(err);
                console.log("getUserCheck Error: " + err);
                document.location.href=_spPageContextInfo.webAbsoluteUrl  + "/SitePages/ERROR.aspx";
            }
    });
 
}  
 // JavaScript source code
NWF$(window).load(function () {

    //make read only
    NWF$('#'+ActivityID).prop("readonly", true);
NWF$('#'+ActivityType).prop("readonly", true);
NWF$('#'+ActivityStatus).prop("readonly", true);
NWF$('#'+StatusReason).prop("readonly", true);
NWF$('#'+CRN).prop("readonly", true);
NWF$('#'+CaseTitle).prop("readonly", true);
NWF$('#'+QADescription).prop("readonly", true);
NWF$('#'+RegardingID).prop("readonly", true);
NWF$('#'+RegardingType).prop("readonly", true);
NWF$('#'+Reviewer).prop("readonly", true);
NWF$('#'+ReviewersTeam).prop("readonly", true);
NWF$('#'+Assessee).prop("readonly", true);
//NWF$('#'+AssesseeTeam).prop("readonly", true);
NWF$('#'+Manager).prop("readonly", true);
//NWF$('#'+Private).prop("disabled", true);
//NWF$('#'+CheckType).prop("disabled", true);
NWF$('#'+QAType).prop("readonly", true);
//NWF$('#'+QAStarted).prop("disabled", true);
//NWF$('#'+QACompleted).prop("disabled", true);
 
NWF$(document).ready(function(){         

NWF$('iframe').contents().find('a').attr("target","_blank");

//replace textarea text with iframe text
//console.log(NWF$('iframe').contents().text());
var txt = NWF$('iframe').contents().text();
NWF$('.nf-richtext').val(txt);
//console.log(NWF$('.nf-richtext').text());
     

//AsseComments
if (NWF$('#'+AsseComments).val() !="")
{

           NWF$('#'+AsseComments).prop("readonly", true);
       NWF$('.btnAssesseeComments').hide();

        }
 
//ManagerComments
if (NWF$('#'+MgrComments).val() !="")
{
//
           NWF$('#'+MgrComments).prop("readonly", true);
NWF$('.btnManagerComments').hide();

            
        }

 
        NWF$('#'+Assessee).change(function() {

if (NWF$('#'+Assessee).val()=="")
{
ClearManager();
ClearComments();
            }

if ((NWF$('#'+Assessee).val()!="")  && (NWF$('#'+AssesseeTeam).val()=="") )
{   
                getTeamsData(NWF$('#'+Assessee).val(), AssesseeTeam);
                      
}
      
        });
//update textarea box height with scroll height
TextAreaResize();
    });

if (Is New Mode)
{ waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose(' ', 'Please wait...', 110, 280);
setTimeout(function () {
waitDialog.close();
}, 5000);

NWF.FormFiller.Events.RegisterAfterReady(function () {NWF$(document).ready(function(){

getInitFormData(NWF$('#'+hidUniqueID).val()); }); });
}
 
    //set QA Completed date on Confirm selection
NWF.FormFiller.Events.RegisterAfterReady(function () {
NWF$("#"+Confirm).change(function () {
if (NWF$("#"+Confirm).prop("checked"))
{
console.log("Checked");
setQACompleted();
}
else
{
console.log("NOT Checked");
NWF$("#"+QACompleted).val('');
}
});});
});

function setQACompleted()
{
var fullDate = new Date() ;
var twoDigitMonth = ("0" + (fullDate.getMonth() + 1)).slice(-2) ;
//var hours = fullDate.getHours();
//var minutes = fullDate.getMinutes();
var currentDate = fullDate.getDate() + "/" + twoDigitMonth + "/" + fullDate.getFullYear();


// Set the date field
NWF$('#' + QACompleted).val(currentDate);
}
function getInitFormData(uniqueID) {
   
var svcInitForm = NWF$('[data-controlname*=svcInitForm] input').val();
//console.log("svcInitForm: " + svcInitForm);
var serviceUri = _spPageContextInfo.webAbsoluteUrl + svcInitForm+ uniqueID;
console.log("serviceUri : " + serviceUri );
NWF$.ajax({
type: "GET",
contentType: "application/json",
url: serviceUri,
dataType: "json",
success:
function (data) {
console.log(data);
if (data.length>0)
LoadInitFormValues(data);
},
error:
function (err) {
console.log("Error: " + err);
}
});
}
 function LoadInitFormValues(data)
{
NWF$('#'+ActivityID).val(data[0].ActivityID);
NWF$('#'+ActivityType).val(data[0].ActivityType);
NWF$('#'+ActivityStatus).val(data[0].ActivityStatus);
NWF$('#'+StatusReason).val(data[0].StatusReason);
NWF$('#'+CRN).val(data[0].CRN);
NWF$('#'+CaseTitle).val(data[0].CaseTitle);
NWF$('#'+QADescription).val(data[0].QADescription);
NWF$('#'+RegardingID).val(data[0].RegardingID);
NWF$('#'+RegardingType).val(data[0].RegardingType);
//NWF$('#'+Reviewer).val(data[0].Reviewer);
var str = data[0].Reviewer;
str=str.substring(str.indexOf('#')+1);
var rev = new NF.PeoplePickerApi('#'+Reviewer);
rev.search(str).done(function (revdata) {
rev.add(revdata[0]);
});

NWF$('#'+ReviewersTeam).val(data[0].ReviewersTeam);

//NWF$('#'+Assessee).val(data[0].Assessee);
var str = data[0].Assessee;
str=str.substring(str.indexOf('#')+1);
var ins = new NF.PeoplePickerApi('#'+Assessee);
ins.search(str).done(function (assedata) {
ins.add(assedata[0]);
});

NWF$('#'+AssesseeTeam).val(data[0].AssesseesTeam);
 console.log(data[0].Private);

 
if (data[0].Private==true)
NWF$("#"+Private).click();NWF$('#'+CheckType).val(data[0].CheckType);
NWF$('#'+QAType).val(data[0].QAType);
//NWF$('#'+QAStatus).val(data[0].QAStatus);

if (data[0].QAStarted!=null)
{
//var inputdate = data[0].QAStarted;
//var iDay = inputdate.slice(0,2);
//var iMonth = inputdate.slice(3,5);
//var iYear = inputdate.slice(6,10); //NWF$("#" +QAStarted).val(iDay + "/" + iMonth + "/" + iYear);
NWF$("#" +QAStarted).val(data[0].QAStarted);
}

if (data[0].QACompleted!=null)
{
//var inputdate = data[0].QACompleted;
//var iDay = inputdate.slice(0,2);
//var iMonth = inputdate.slice(3,5);
//var iYear = inputdate.slice(6,10); //NWF$("#" +QACompleted).val(iDay + "/" + iMonth + "/" + iYear);
NWF$("#" +QACompleted).val(data[0].QACompleted);
}

NWF$('#'+UniqueID).val(data[0].UniqueID);
NWF$('#'+QAURL).val(data[0].QAURL);

}

 
function SetManager(smgr) {

if (smgr!="")
{
var mgr= new NF.PeoplePickerApi('#'+Manager);
mgr.search(smgr).done(function (revdata) {
mgr.clear();
mgr.add(revdata[0]);
});
}

return smgr;
}

function ClearManager() {
var mgr= new NF.PeoplePickerApi('#'+Manager);
mgr.clear();
}
 
function ClearComments() {
NWF$('#'+AsseComments).val('');
NWF$('#'+MgrComments).val('');
NWF$('#'+AssesseeTeam).val('');
}
function CloseCheck()
{
    if (confirm("If you Close now, you will lose any data entered! Press OK to continue, or Cancel to stay on the current page.") == true) {
         window.top.location.href= "/" ;
return true;
    }
 else {
      
return false; 
    }
}

function TextAreaResize()
{
//increase textarea box size to see all content
NWF$('.text-area').on('change', 'textarea, div', function () {
              NWF$(this).height(this.scrollHeight);
    }).find('textarea, div').change();//remove event handler
NWF$('.text-area').off('change')
}
  
function getTeamsData(userName, teamCtrl) {
 var str = userName;
    var res = str.substring(str.indexOf('\\')+1, str.indexOf(';'));
var svcUserlevels = NWF$('[data-controlname*=svcUserLevels] input').val();
//console.log("svcUserLevels: " +  svcUserlevels );
var serviceUri = _spPageContextInfo.webAbsoluteUrl + svcUserlevels + res;
    NWF$.ajax({
        type: "GET",
        contentType: "application/json",
        url: serviceUri,
        dataType: "json",
        success:
            function (data) {
                if (data.length>0)
                     NWF$('#'+teamCtrl).val(data[0].GroupName);
       
            },
        error:
            function (err) {
                console.log("getTeamsData Error: " + err + " uname: " + userName + " Ctrl: " +teamCtrl);
            }
    });
}

  
function getConfigValue(configKey) {
//var svcConfigValueUrl = NWF$('[data-controlname*=svcGetConfigValue] input').val();
var svcConfigValueUrl = "/_vti_bin/QAService.svc/GetConfigValue/";
//console.log("svcConfigValueUrl " + svcConfigValueUrl );
var serviceUri = _spPageContextInfo.webAbsoluteUrl + svcConfigValueUrl + configKey;
 console.log("serviceUri " + serviceUri);
    NWF$.ajax({
        type: "GET",
        contentType: "application/json",
        url: serviceUri,
        dataType: "json",
        success:
            function (data) {
                if (data.length>0)
                 {
                     var res = data[0];
                     res = res.replace("{0}", NWF$('#'+ActivityType).val());
                     res = res.replace("{1}", NWF$('#'+ActivityID).val());
                     
                     console.log(res);
                     window.open(res, '_blank');
                  }
       
            },
        error:
            function (err) {
                alert(err);
                console.log("getConfigValue Error: " + err);
            }
    });
}

 

Any help would be greatly appreciated. 

Labels: (1)
0 Kudos
Reply
1 Reply
Highlighted
Automation Master
Automation Master

Re: Rules not applying after Nintex forms upgrade

It looks to me as if the JavaScript you've posted here is what's preventing people from accessing certain controls (based off of the many '.prop("readonly", true);' lines). 

that being said, if you are really certain that it's a rule on the form (made using the rule editor) that is preventing people from editing the form, then I'd recommend removing all of your javascript and testing to see if the rule works outright. 

if it does, then start placing chunks of your code back until you find that the rule is no longer working, and hunt for problems with the recently added code block. 

You can also always load your form having first opened the Dev Panel (in Chrome / FireFox - press F12) to see if you're getting any Error Messages in the Console. 

If you are, it would be wise to post those messages here as it may help in evaluating what's happening. 

without knowing anything about the form or your environment, it's difficult to tell how your code could be causing problems as we have no references as to what it's doing. 

0 Kudos
Reply