Managed Metadata

rss

Posted by stieland - Feb 25 ’14 at 02:49

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?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 24 days
    #1 by Dmitry Kozlov Feb 26 ’14 at 07:50

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

    var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0);
    container.JavascriptOnValidation = "alert('Managed metadata changed!')"; 
    
  • stieland
    Member
    Member for: 6 years 6 months 1 day
    #2 by stieland Feb 26 ’14 at 03:53

    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.

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 24 days
    #3 by Dmitry Kozlov Feb 27 ’14 at 04:14

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

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

    Getting:

    var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0);
    var taxCtlObj = new Microsoft.SharePoint.Taxonomy.ControlObject(container);
    var termValue = taxCtlObj.getRawText();
    
  • Christian Heinrich
    Christian Heinrich
    Member
    Member for: 4 years 10 months 10 days
    #4 by Christian Heinrich Feb 3 ’15 at 10:56

    [#1]: 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...

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 24 days
    #5 by Dmitry Kozlov Feb 4 ’15 at 07:42

    [#4]: Please, try the following code for SP2010:

    var container = fd.field('TermStore1').control()._el().find('div.ms-taxonomy').get(0);
    container.JavascriptOnValidation = "alert('Managed metadata changed!')"; 
    
  • SophiaSmith2395
    Member
    Member for: 4 years 10 months 6 days
    #6 by SophiaSmith2395 Feb 6 ’15 at 08:39

    The message was removed by a forum moderator.

  • Dan
    Member
    Member for: 4 years 7 months 17 days
    #7 by Dan Aug 10 ’15 at 01:53

    [#1]: 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!");

    }

     

     

     

  • rostislav
    rostislav
    Moderator
    Member for: 4 years 7 months 8 days
    #8 by rostislav Aug 11 ’15 at 04:24

    [#7]:

    You can define a global function and then call it:

    container.JavascriptOnValidation = "func()";
    
    window.func = function () { 
       console.log("Managed Metadata Changed!");
    }
    
  • Dan
    Member
    Member for: 4 years 7 months 17 days
    #9 by Dan Aug 12 ’15 at 11:08

    [#8]:

    That worked! Thanks!

  • Katy
    Member
    Member for: 5 years 4 months 28 days
    #10 by Katy Oct 5 ’16 at 03:39

    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?

Displaying 1 to 10 of 12 messages
Previous12