How to copy a Managed Metadata value to a single line text field?

  • 20 November 2017
  • 4 replies
  • 3 views

Badge +5

Using on-prem SP & Nintex 2016.

I need to copy the value in a managed, metadata field called Route.  The javascript client ID is vRouteMMD.  The target field is called RouteCopy with a javascript client ID of vRouteCopy.  RouteCopy is not connected to any column.  I have used the follow javascript (note the "alert" returned 'undefined' when un-commented).  RouteCopy does not get populated.  I have tried numerous variations on this code, but no joy.  sad.png  Its seems so simple . . .

NWF$(document).ready(function(){
var varRouteMMD = NWF$('#' + vRouteMMD).val();
//alert(varRouteMMD);
NWF$('#' + vRouteCopy).val(varRouteMMD);
});

Any suggestions would be greatly appreciated!

-Ken


4 replies

Userlevel 5
Badge +9

Hi Ken,

Can you try the following code?

NWF$(document).ready(function(){ NWF.FormFiller.Events.RegisterAfterReady(function() {
var mm = NWF$("#" + vRouteMMD);
var mm2 = NWF$("#" + vRouteCopy);
mm2.find("input[type='hidden']").val(mm.find("input[type='hidden']").val());
mm2.find(".ms-inputBox").append(mm.find(".ms-inputBox")[0].innerHTML);
}); });

Hope this works

Badge +2

Caroline,

Thanks for the insight into getting the value from a Managed Metadata form control!

I have tried using this to put the MM form control value into a calculated field control.

However, the calculated field control does not get updated when the MM form control value changes (the MM form control does not seem to trigger the recalculation of CV fields).....

Am I missing something on getting a second form control field to automatically update when the MM form control value changes?

Userlevel 5
Badge +9

Sorry for the late reply.

If you'd like the calculated value to be updated when the MM form control value changes, you need to add the reference to the MM named control into the calculated value.

Hope this helps

Badge +11

@cju can you please assist.

 

I have the same scenario:

1 x MetaData field to select various locations from

1 x single text field.

 

I like to update the single text field with the location mame which is in the MetaData. So, if a user selects a location from the MetaData (even on change / update) it should replicate it to the single text field.

 

This is what I have done so far:

 

MetaData field> Client ID JS Variable Name : varMetaData

Single Text field > Client ID JS Variable Name : varCopyMetaData

 

Custom Javascript:

 

NWF$(document).ready(function(){
NWF.FormFiller.Events.RegisterAfterReady(function() {

var mm = NWF$("#" + varMetaData);
var mm2 = NWF$("#" + varCopyMetaData);
mm2.find("input[type='hidden']").val(mm.find("input[type='hidden']").val());alert(mm);mm2.find(".ms-inputBox").append(mm.find(".ms-inputBox")[0].innerHTML);
}); });

 

Where do I assign the .ms-inputBox to?

Reply