Skip to main content

I need to get value of Managed Metadata field onchange using custom javascript in Nintex form  in order to show/hide another field.

I have tried what is suggested on this forum  How do you validate Managed Metadata Field in a Nintex Form  but to no avail. 

I tried this simple custom validation on the control to get the value but it is not firing, no alert displaying:

function getValue(source, arguments)

{

alert(arguments.Value);

}

211289_pastedImage_1.png

If anyone can suggest what i am missing here, that will be highly appreciated.

The tooltip in your screenshot says that the value of your managed metadata field will NOT be provided to your validation function.

This means you need to get the fields value manually inside your validation function. See ‌s answer in the post you referenced to see what can be done here.

Cheers

Philipp


Thanks for the reply Philipp Lucas Lucas. I tried what Caroline Jung suggested, still not able to alert the value. Am I missing something? I guess I am struggling where to apply that code she provided, under custom javascript section or under custom validation function in the control? How to test what value is stored?

Thanks for your help!


Best Practice would be to store the code inside a JS-File. Upload that JS-File to your SharePoint-Site (e.g. SiteAssets Library) and reference it inside your form settings. But for a small test you can also put this code inside the custom javascript section.

Inside the funtion you need to query the control from which you want to get the value from like NWF$("#"+MyFieldID).value() and you can alert this value to test it.


I used Using SharePoint TaxonomyWebTaggingControl control: Access and manipulate from client side | YASP Blog 

and added as Custom Javascript to form:

NWF.FormFiller.Events.RegisterAfterReady(function () {
    ExecuteOrDelayUntilScriptLoaded(initTaggingControl, 'ScriptForWebTaggingUI.js');
});

function initTaggingControl() {
    RTE.CanvasEvents.registerListener(RTE.CanvasEvents.editableRegionChangedEvent,
        Function.createDelegate(null, OnTaxonomyDataUpdatedDelegate));
}

function OnTaxonomyDataUpdatedDelegate() {
   //do whatever you want when value of taxonomy field changes
}

Thanks Antonina, your post was the final solution. The event handler worked for all fields but not for metadatefields in nintex forms. With your code, also the metadafield eventhandler were fine 🙂


I used the method from Antonina to copy the value to a hidden textField. Then I can use the rules to react on the hiddenTextField.

Finally to make to rules check the new value, use the trigger("blur") Method. Then the rules start taking effect of the new value,

txtField.trigger("blur");

This helped me to design a Nintex Form using Metadata fields and hide/show depending on the Metadatefields additional panels and fields.


 


Mycode Example:


 


NWF.FormFiller.Events.RegisterAfterReady(function () {


CheckVertragstyp();

ExecuteOrDelayUntilScriptLoaded(initTaggingControl, 'ScriptForWebTaggingUI.js');});
function initTaggingControl() { RTE.CanvasEvents.registerListener(RTE.CanvasEvents.editableRegionChangedEvent, Function.createDelegate(null, OnTaxonomyDataUpdatedDelegate));}function OnTaxonomyDataUpdatedDelegate() {
CheckVertragstyp()}


function CheckVertragstyp(){
NWF$("#" +VertragstypHiddenField).val(NWF$("#" +Vertragstyp_ClientID).find("inpututype='hidden']").val()).trigger("blur");
}


Reply