cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to get the usergroup by tag in a service

adityak0195
6-Contributor

How to get the usergroup by tag in a service

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
ACCEPTED SOLUTION

Accepted Solutions

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".

View solution in original post

1 REPLY 1

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".

Announcements


Top Tags