Skip to main content
1-Visitor
October 15, 2019
Solved

How to get the usergroup by tag in a service

  • October 15, 2019
  • 1 reply
  • 1174 views
I have tagged some usergroups by tag and project in a general information page. Now, I want to get the usergroup by by tags in a service. How to achieve it.
Thanks
Best answer by eliotlandrum

You can use the SearchModelTagTerm service to find it.

 

 

var params = {
	maxItems: undefined /* NUMBER */,
	types: {"items": ["Group"]} /* the type of item you're looking for */,
	names: { "items": ["TW"] } /* change to your Vocabulary name */,
	term: "Demo" /* change to your Term */
};

// result: INFOTABLE dataShape: EntityDescriptor
var result = Resources["SearchFunctions"].SearchModelTagTerm(params);

 

 

For this example, I had previously tagged a User Group with the "TW:Demo" tag (TW is the Vocabulary and Demo is the Term) and this code returned that item. (For a list of all the options for Types, check out this forum post.)

 

Note, though, that if the term exists it also returns as the first row "TW~ModelTagVocabulary". I found mention of this as a bug, but am unsure of the status of it. In my code I've worked around it by skipping if the ID is "TW~ModelTagVocabulary".

1 reply

14-Alexandrite
October 15, 2019

You can use the SearchModelTagTerm service to find it.

 

 

var params = {
	maxItems: undefined /* NUMBER */,
	types: {"items": ["Group"]} /* the type of item you're looking for */,
	names: { "items": ["TW"] } /* change to your Vocabulary name */,
	term: "Demo" /* change to your Term */
};

// result: INFOTABLE dataShape: EntityDescriptor
var result = Resources["SearchFunctions"].SearchModelTagTerm(params);

 

 

For this example, I had previously tagged a User Group with the "TW:Demo" tag (TW is the Vocabulary and Demo is the Term) and this code returned that item. (For a list of all the options for Types, check out this forum post.)

 

Note, though, that if the term exists it also returns as the first row "TW~ModelTagVocabulary". I found mention of this as a bug, but am unsure of the status of it. In my code I've worked around it by skipping if the ID is "TW~ModelTagVocabulary".