Page 1 of 1
Check the value in metadata field
Posted: 20 Apr 2017
by Katy
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
Re: Check the value in metadata field
Posted: 21 Apr 2017
by Dmitry Kozlov
Hi,
Please, read the thread:
viewtopic.php?f=1&t=615
Re: Check the value in metadata field
Posted: 21 Apr 2017
by Katy
Yes, I've read it... my alert doesn't come at all: even if the value is already there, not just on change; and I don't know how to check specific value of a field... I'll re-read again, maybe I'm missing something...
Re: Check the value in metadata field
Posted: 24 Apr 2017
by Dmitry Kozlov
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!')";
Re: Check the value in metadata field
Posted: 24 Apr 2017
by Katy
I don't really need to check it on change: i need to check if a certain text is there -> if the field = X. I don't actually need to check on change as this is on Edit form already.
Re: Check the value in metadata field
Posted: 25 Apr 2017
by Dmitry Kozlov
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
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();
viewtopic.php?f=1&t=615
Re: Check the value in metadata field
Posted: 02 Jun 2017
by Katy
Sorry, i haven't replied to this: it works fine! Thank you very much!
One thing only - i have it on my edit form and if i make matadata field read only the code stop working....