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.
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.
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.argumentss2];
var targetControl = sourceContext.find("sformcontrolid='" + 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("dformcontrolid='" + 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.
Ah! I see!
Well, you're going to create a Rule for your control, and put it into there.
Here is what my form looks like:
First: Select the controls that you want to manipulate:
Second: In the top Ribbon, add a new rule by clicking on the Add Rule button:
Third: The Rule Panel will open from the right side of your screen, and from there you will be able add the code that I have posted above into the Condition section of the Rule, and it will apply to all of those selected controls! Make sure that you also change the Rule Type to Formatting and check the Disable box near the bottom of the dialog. I have highlighted all of those fields in the image below.
I hope that this helps you on your way. If you need additional help, please ask.
Thank you so much! I will work on this today.
Thank you so much for he code. This worked!
Could you please mark my answer as the Solution to this problem so that others will be able to quickly see how to accomplish this as well?
Thank you, and I'm very happy that it worked for you!
I really appreciate your help!
By the way, where do you mark the answer as 'Solution' on this page?
It would seem that a Nintex Staff Member or Moderator has already taken care of it and marked my answer as the Solution!
No worries!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.