Skip to main content

Hi!  I am trying to auto insert a runtime value into a field based on the content of another.  Both fields are open text fields.

If the User inputs "various" into PlanName.  I would like "various" to auto-appear in the PlanNumber field.  The JS I have doesn't work accordingly.  Please help!

  if(spUtilities.nintexControl("PlanName").val() == "various") spUtilities.nintexControl("PlanNumber").val("various");

Are you using Classic or Responsive Forms? 

You say that you're just using two open ("open" in this case I assume meaning "enabled" and able to be altered at any given time by a user), and if one of the Controls contains the word "various" you'd like the word "various" to appear as the Value of the second Control, yes? 

  • What happens if someone then erases the value from the Second Control?
    • Should they be able to? Should it be locked down?
  • Would this information better be displayed by something such as a Calculated Value?
  • Is there a Default message that exists in the Second Control when the word Various doesn't exist in the First Control?
  • Are there any other 'keywords' that require a similar methodology?

Please provide answers and context for the above questions, as it could be useful in allowing people to generate an answer for you. 


Thank you for the reply!

If they type Various (or various) in Plan Name, I would like Various to appear in Plan Number.  But would also like them to have the ability to type over the Various wording.

No default messaging int he 2nd control.  Typically, they would just enter a contract number.  But on occasion, there are several contract numbers, to which we would just accept the word Various.  Though, if there are only 2 numbers, I'd like them to have the ability to type over the word if they wish.


Alrighty. 

And one last one (which I just thought of) 

What happens if there is already something in that second control where the word 'Various' should appear suddenly? Should it just overwrite everything, get added as a prefix or suffix, or just not show up at all? 


Thanks again for your help!

If something already exists in that 2nd field, I would like for it to stay.  So the "Various" would only pop in there IF the field is blank.


In my test form I have (2) Label Controls and (2) Single Line Text Controls 

218161_pastedImage_1.png

First Single Line Text Control:

218186_pastedImage_2.png

Second Single Line Text Control: 

218187_pastedImage_3.png

on the Second Single Line Text Control, Create a Formatting Rule:

218188_pastedImage_4.png

(Note: You do not need to select either Disable or Hide as we are just using this to interact with the control it's attached on and aren't actually formatting it happy.png)

...and insert the following text: 

(function(formControlCall, inputVal) {
  "use strict";

  var formControlID = formControlCall.split("'")>1] || "";
  var targetControl = sourceContext.find(">formcontrolid='" + formControlID + "'].nf-filler-control");
  var targetInput = NWF$(targetControl.find("nformcontrolid]oid]")a0]);

  if (inputVal.match(/various/gi) !== null && !targetInput.val()) {   
    targetInput.trigger("focus").val("Various").trigger("blur");
  }

  return false;
}("{Control:Self}", First_Input))

(Note: At the very bottom there, 'First_Input' should be the actual reference to the named control on the form. Here is a picture showing what the formula should look like in your editor

218189_pastedImage_5.png

This will input the word "Various" inside of the Second Input Control, so long as the First Input Control contains the word (in any upper or lowercase format) - anywhere in the text AND only if the second field is empty. 

218190_pastedImage_18.png

Not exactly a pretty way of achieving this, but if it works for you and your users are happy, it works. 

Hope it helps! 


Reply