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.
Solved! Go 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.
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.
/* 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, {Control:Self}));
*/
Thank you for posting your code. I will try this today.
Celso
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.
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!
Much appreciated!
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!
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.