AnsweredAssumed Answered

How to trigger javascript function when Managed Metadata form control field value changes?

Question asked by dweyrick on Nov 8, 2018
Latest reply on Nov 13, 2018 by chaddavis

I have a Managed Metadata (MM)  form field and a single line text form field (TXT) on a Nintex form (using version 2.11.4.0).

 

Goal:  When the value in the MM form field changes, I would like the value to be written to the single line text field.

I will then use the value from the TXT field in a List Lookup control to filter values in the drop-down list for the user.

 

I have put together the following custom JavaScript functions for to achieve this (with much help from posts by the post 

 How Do You Validate Managed Metadata Field in a Nintex Form:

 

function SetFieldValue(cbfield, cbfieldval) {
NWF$('#'+ cbfield).val(cbfieldval);
}

 

function getMDFieldValue(varMDField) {
var mm = NWF$("#" + varMDField);
var mmv = mm.find("input[type='hidden']").val();
return mmv;
}

 

My MM form field has a Javascript Control ID of jsDeptMMD.   My TXT form field has a Javascript Control ID of jsDeptTXT.

 

I use the following statement to run the "SetFieldValue" JavaScript function:

SetFieldValue(jsDeptTXT, (getMDFieldValue(jsDeptMMD)));

 

I have tested this in the IE Developer console by manually typing the command into the IE Console and it works fine to update the TXT form field (see attached screenshot).

 

However, when I place this same JavaScript function call in the Validation function of the MM form field, it does not seem to fire (nothing appears in the TXT form field).   I have also tried using a Calculated Value form field to update the TXT form field - but changing the MM form field value does not seem to trigger the firing of calculated value form fields.

 

Been knocking myself out on this for a couple days trying several things but unable to get anything to trigger the javascript function when the MM form field value changes......

 

Any assistance you can lend me in getting the "SetFieldValue" JavaScript function to run when the value in the MM form field changes will be greatly appreciated!!

Attachments

Outcomes