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

Repeating Section

Jump to solution

How does one disable already filled-in fields, in repeating sections, after the form is saved, and reopened for editing?

Thank you for your help.

Reply
15 Replies
sakhatri
Nintex Newbie

Re: Repeating Section

Jump to solution

As i understand , you want to disable all the fields in the repeating section which the users have already filled-in.
To do so, create a new rule by selecting all the controls to which the rule should apply.

Reply
Automation Master
Automation Master

Re: Repeating Section

Jump to solution

Using Saud's rule above, it will indeed lock things that are already filled out, but has the downfall of instantaneously locking any field that is filled out at all, which creates the assumption that a user will fill things out correctly the first time with no typos!

The following rule that I have made will run at the beginning of each controls creation, and based on the emptiness of the control, will either place a locking css class on it (in the event that it already has a value), or a css class which indicates that it is to be ignored (in the event that it was blank). 

This way, you will have the ability to fill in blank or new controls, without locking them, which won't screw up any secondary validation that might be taking place in other rules. 

If this solution works and you'd like to learn more about it, I'll come back around and write up a more detailed post as to how it works. 

The Code: 

(function(sourceContext, callerThis, controlValue) {
  var targetFormControlID = callerThis.Name.caller.arguments[2];
  var targetControl = sourceContext.find("[formcontrolid='" + targetFormControlID + "'].nf-filler-control");

  if (!targetControl.hasClass("ignoreMe") && !targetControl.hasClass("lockMe")) {
    if (typeof controlValue !== "number" && typeof controlValue !== "string") {
      if (NWF$.type(controlValue) === "array" && controlValue.length > 0) {
        controlValue = controlValue.toString();
      } else {
        controlValue = "";
      }
    }

    if (!controlValue && !targetControl.hasClass("ignoreMe")) {
      targetControl.addClass("ignoreMe");
    } else {
      targetControl.addClass("lockMe");
    }
  }

  return targetControl.hasClass("lockMe");
}(sourceContext, this, {Control:Self}));‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

EDIT (1): It should also be noted that I believe that this code / rule should work in any field anywhere on the form. Not just the ones that reside inside of Repeating Sections. The End. 

Edit (2): So I remembered that using the 'callerThis.Control' is unreliable depending on the control you are targeting and the Control(s) responsible for firing the initializing event! Unfortunately the workaround (which can now be seen in the above code as the 'targetFormControlID' variable) is incredibly ugly, and is not compatible with 'use strict' mode, but is the only guaranteed way to always find the correct formcontrolid attribute of the target control in question. Perhaps at some point the Nintex team will consider creating property inside of the context's this that is passed into the rule that contains the correct attribute rather than a variable one.

No matter. I have included the old (bad) code below this change, in the event that someone was interested in what changed. Don't use the below (bad) code! 

/* THIS IS THE OLD CODE! DO NOT USE THIS !!!! 

(function(sourceContext, callerThis, controlValue) {

  var targetControl = sourceContext.find("[formcontrolid='" + callerThis.Control + "'].nf-filler-control");

  if (!targetControl.hasClass("ignoreMe") && !targetControl.hasClass("lockMe")) {
    if (typeof controlValue !== "number" && typeof controlValue !== "string") {
      if (NWF$.type(controlValue) === "array" && controlValue.length > 0) {
        controlValue = controlValue.toString();
      } else {
        controlValue = "";
      }
    }

    if (!controlValue && !targetControl.hasClass("ignoreMe")) {
      targetControl.addClass("ignoreMe");
    } else {
      targetControl.addClass("lockMe");
    }
  }

  return targetControl.hasClass("lockMe");
}(sourceContext, this, {ControlSmiley Frustratedelf}));‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

*/
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

Reply
Automation Master
Automation Master

Re: Repeating Section

Jump to solution

Excellent, ‌!

Reply
cbanquer
Nintex Newbie

Re: Repeating Section

Jump to solution

Thank you for posting your code. I will try this today.

Celso

Reply
cbanquer
Nintex Newbie

Re: Repeating Section

Jump to solution

Thank you Saud! I have tried this rule before I posted my question. My problem with this is it disables the control right after I type the first letter.

Reply
Automation Master
Automation Master

Re: Repeating Section

Jump to solution

Please note that I have made a change to my post, as I came to a realization working on something else today that also involved the use of a formatting rule (that is targeting a control). 

If you do some testing, please use the updated / edited code! 

Reply
cbanquer
Nintex Newbie

Re: Repeating Section

Jump to solution

Much appreciated!

0 Kudos
Reply
Highlighted
Automation Master
Automation Master

Re: Repeating Section

Jump to solution

Did you have a chance to test this? If you need additional help or instruction, feel free to ask. However, If it works, could you please update the thread as solved?

Thank you! 

Reply
cbanquer
Nintex Newbie

Re: Repeating Section

Jump to solution

I'm sorry, I was pulled into some other tasks.

I am very new to Nintex so I really do not know where to place this code. I

have just started exploring the 'Custom Javascript' section.

Thank you.

Reply