Managed Metadata

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
stieland
Posts: 17
Joined: Thu Jun 13, 2013

25 Feb 2014

I am trying to work with Managed Metadata fields and have not been able to pick up the change event for a Managed Metadata field.

fd.field('RCategory').change(function() {
alert('Category Changed');
});

Never fires the alert. Do Managed Metadata fields work differently?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

26 Feb 2014

Please, try to use the following code to handle changing of Management Metadata field:

Code: Select all

var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0);
container.JavascriptOnValidation = "alert('Managed metadata changed!')"; 

stieland
Posts: 17
Joined: Thu Jun 13, 2013

26 Feb 2014

While that is firing when the item is updated, also a few more times. I am still missing a few items to get my piece working.

I need to know when the managed metadata field equals 'Option 2' and if it equals 'Option 2', then I need to make another control visible. If it does not equal 'Options 2' then the other control is hidden.

I do not seem to be able to get the value of the managed metadata field so that I can compare it.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

27 Feb 2014

You can find examples of getting and setting Taxonomy field values in the following article:

http://blog.vgrem.com/tag/taxonomywebtaggingcontrol/

Getting:

Code: Select all

var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0);
var taxCtlObj = new Microsoft.SharePoint.Taxonomy.ControlObject(container);
var termValue = taxCtlObj.getRawText();

User avatar
Christian Heinrich
Posts: 5
Joined: Tue Feb 03, 2015

03 Feb 2015

Should that alternat event registration also work for SP 2010?

I did put that code into the JavaScript part of the form, but the alert never shows up...

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 Feb 2015

Please, try the following code for SP2010:

Code: Select all

var container = fd.field('TermStore1').control()._el().find('div.ms-taxonomy').get(0);
container.JavascriptOnValidation = "alert('Managed metadata changed!')"; 

Dan
Posts: 4
Joined: Tue Apr 28, 2015

10 Aug 2015

It seems like the only thing you can do in here is report out that it's fired. Trying to call an handler function doesn't seem to work properly. I've tried a couple things and some variations of them:


container.JavascriptOnValidation = "mmChangeHandler()";


function mmChangeHandler() {

console.log("Managed Metadata Changed!");

}

/* OR */

container.JavascriptOnValidation = function() {

console.log("Managed Metadata Changed!");

}

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

11 Aug 2015

You can define a global function and then call it:

container.JavascriptOnValidation = "func()";

Code: Select all

window.func = function () { 
   console.log("Managed Metadata Changed!");
}

Dan
Posts: 4
Joined: Tue Apr 28, 2015

12 Aug 2015

That worked! Thanks!

Katy
Posts: 145
Joined: Wed Dec 02, 2015
Location: Canada

05 Oct 2016

Hi!

I checked with alert and it works fine indeed. I need to insert the check for mandatory field with metadata. I tried some options like:

fd.field('FieldName').control()._el().find('.ms-taxonomy').value()

fd.field('FieldName').control()._el().find('.ms-taxonomy').value() == ""

fd.field('FieldName').control()._el().find('.ms-taxonomy').length > 0

but nothing works :-( Howcan I use it in IF statement to check if the metadata field contains any information?

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests