Check the value in metadata field
I am trying to do a check on managed metadata field, but can't make it work. Please, help me. I am using this code:
function setSSRoles() {
if (fd.field('Facility').control()._el().find('.ms-taxonomy').value() == 'E001 - Corporate') {
alert('Corporate');
}
}
fd.field('Facility').change(setSSRoles);
setSSRoles();
And i tried to put the whole GUID line into value() == as well
function setSSRoles() {
if (fd.field('Facility').control()._el().find('.ms-taxonomy').value() == 'E001 - Corporate') {
alert('Corporate');
}
}
fd.field('Facility').change(setSSRoles);
setSSRoles();
And i tried to put the whole GUID line into value() == as well
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
The code below shows an alert box when a user changes a taxonomy field:
Code: Select all
var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0);
container.JavascriptOnValidation = "alert('Managed metadata changed!')";
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
The following code returns all tags with their identifiers. Then you can check if a particular value is there with the indexOf function: https://www.w3schools.com/jsref/jsref_indexof.asp
viewtopic.php?f=1&t=615
Code: Select all
var container = fd.field('Tags').control()._el().find('.ms-taxonomy').get(0);
var taxCtlObj = new Microsoft.SharePoint.Taxonomy.ControlObject(container);
var termValue = taxCtlObj.getRawText();
-
- Information
-
Who is online
Users browsing this forum: No registered users and 4 guests