dweyrick
Forms Fledgling

Re: How do you validate Managed Metadata Field in a Nintex Form

Caroline:  Excellent information - exactly what I am looking for with a new Nintex form!   I have been using Nintex forms and workflow for a couple years but still struggle to work properly with managed metadata fields effectively from forms or workflow....

I'm looking for some detail on how to "call" this method within the Nintex form in order to validate the MM field value:

- Is it configured as the Custom Validation function?

- Does this last version of your method still get inserted inside a validation function (as outlined by graham.williamson above) in order to call/activate it?   Or can it be called directly after placing it alone inside the "Custom Javascript" area of the Form Settings?

Any details you can give on how to setup this method for use in a Nintex form will be greatly appreciated!!

0 Kudos
Reply
cju
Automation Master
Automation Master

Re: How do you validate Managed Metadata Field in a Nintex Form

Hi David,

I'm glad that it can help you .

To being able to use it, you need to :

  • add the whole javascript function in the "Custom Javascript" area of the Form Settings (or in the javascript file that you can reference in the "Advanced" area of the Form settings)
  • set "Use custom validation" to "Yes" in the "Validation" area of the settings of the managed metadata field
  • set "Custom validation function" with "managedMetadataValidationFunction" in the "Validation" area of the settings of the managed metadata field

Hope this helps

0 Kudos
Reply
kjhawkins
Nintex Newbie

Re: How do you validate Managed Metadata Field in a Nintex Form

Caroline,

I'm a bit lost on how the function works.  For each MMD field on the form do you need to add a corresponding "Client ID Javascript variable name"?    How would I modify this if I only wanted to verify that a selection was made for each MMD field?

Sorry for the questions, but Managed Metadata fields seem a bit convoluted to me. 

Regards,

Ken

0 Kudos
Reply
cju
Automation Master
Automation Master

Re: How do you validate Managed Metadata Field in a Nintex Form

Hi Ken,

Sorry for the delay and the confusion .

With the last javascript function that I provided in this discussion, you don't need to add each MMD client ID in a javascript variable. It's a better version than the first javascript function I shared .

You just need to reference the javascript function in the form settings and edit the control settings of each MMD field to set  "Use custom validation" to "Yes" and "Custom validation function" with "managedMetadataValidationFunction" and that's all .

Tell me if it's not clear

Reply
kjhawkins
Nintex Newbie

Re: How do you validate Managed Metadata Field in a Nintex Form

Ah...now I get it!  Thank you for clearing that up for me.

Ken

0 Kudos
Reply
cju
Automation Master
Automation Master

Re: How do you validate Managed Metadata Field in a Nintex Form

Perfect ! I'm glad I could help

0 Kudos
Reply
kjhawkins
Nintex Newbie

Re: How do you validate Managed Metadata Field in a Nintex Form

Caroline,

I've finally gotten around to working with your validation code.  It works...somewhat.  For some reason it produces a validation error regardless if the field is populated or not.  If I enter a new value and save/submit, the error persists.

We are using a document library with checkout/check-in and versioning enabled (if it makes any difference).

Any ideas why it would behave in this manner?

Ken  

Here is what I have in the Custom Javascript:

function managedMetadataValidationFunction(source, arguments) {
    arguments.IsValid = true;    // To check the number of terms populated
    if (NWF$(source).parent().find("span.valid-text").length != 1) {
        arguments.IsValid = false;
    }
    // To check the name of the terms populated    
    var testTermPopulated = false;
    // For each term populated in the managed metadata field
    NWF$(source).parent().find("span.valid-text").each(function() {
        if (NWF$(this).text() == "Test term") {
            testTermPopulated = true;
        }
    });    // If a specific term is not populated    
    if (!testTermPopulated) {
        arguments.IsValid = false;
    }
    //alert(testTermPopulated);
};
0 Kudos
Reply
kjhawkins
Nintex Newbie

Re: How do you validate Managed Metadata Field in a Nintex Form

Since we only needed to test for an empty value, we alter the script (see below) and now it works as needed.

function managedMetadataValidationFunction(source, arguments) {
arguments.IsValid = true;
if (NWF$(source).parent().find("span.valid-text").length != 1) {
arguments.IsValid = false;
}
};

Thank you!

0 Kudos
Reply
cju
Automation Master
Automation Master

Re: How do you validate Managed Metadata Field in a Nintex Form

Hi Ken,

Yes that's correct. The previous script you posted was to check if the managed metadata field had a term which label is "Test term" and not only if a term was populated or not.

Thanks for your feeback

0 Kudos
Reply