Skip to main content
Best answer by mnarang

Using the above service code mentioned by me, you can extract all the entities which are tagged with your tag. Once you get all those entities you have to loop through them and on the basis of parentType/parentName you can remove the tag on a particular entity name. For example, if you have parentType/parentName in the row as mashup then using the name column you can remove the tag. //below is just a sample code to explain how you can do it, I just wrote it but did not test the loop.

 

let params = {
maxItems: undefined /* NUMBER */,
searchExpression: undefined /* STRING */,
types: undefined /* JSON */,
aspects: undefined /* JSON */,
excludedAspects: undefined /* JSON */,
maxSearchItems: undefined /* NUMBER */,
tags: "ABC:Test" /* TAGS */
};

// result: INFOTABLE dataShape: EntityDescriptor
let table = Resources["SearchFunctions"].SearchModelEntities(params);

for(var a=0;a<table.length;a++)

{

If(table[a].parentType/parentName="Mashup")

Mashups[table[a].name].RemoveTags({
tags: "ABC:Test" /* TAGS */
});

else if (table[a].parentType/parentName="Thing")

{

Things[table[a].name].RemoveTags({
tags: "ABC:Test" /* TAGS */
});

//for all the different parentType/Name

}

}

1 reply

5-Regular Member
July 14, 2021

Can you try this snippet, pass you model tag:

let params = {
maxItems: undefined /* NUMBER */,
searchExpression: undefined /* STRING */,
types: undefined /* JSON */,
aspects: undefined /* JSON */,
excludedAspects: undefined /* JSON */,
maxSearchItems: undefined /* NUMBER */,
tags: "ABC:Test" /* TAGS */
};

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

17-Peridot
July 14, 2021

Thanks @mnarang .

1. I have 100 entities under single modeltag. If i want to remove all of them means, should i edit each entity to remove model tag??

2. If n number of tags provided to single entity means, it will consume any amount of memory? 

3. I tried this code and this is not working. then what is the right way to use these services.?

 

try {

Mashups["TrialMashup3"].Resources["SearchFunctions"].RemoveTags("Role:Abhishek");

} catch(err) {

logger.warn(err+"in linenumber "+err.lineNumber);

}

 

mnarang5-Regular MemberAnswer
5-Regular Member
July 15, 2021

Using the above service code mentioned by me, you can extract all the entities which are tagged with your tag. Once you get all those entities you have to loop through them and on the basis of parentType/parentName you can remove the tag on a particular entity name. For example, if you have parentType/parentName in the row as mashup then using the name column you can remove the tag. //below is just a sample code to explain how you can do it, I just wrote it but did not test the loop.

 

let params = {
maxItems: undefined /* NUMBER */,
searchExpression: undefined /* STRING */,
types: undefined /* JSON */,
aspects: undefined /* JSON */,
excludedAspects: undefined /* JSON */,
maxSearchItems: undefined /* NUMBER */,
tags: "ABC:Test" /* TAGS */
};

// result: INFOTABLE dataShape: EntityDescriptor
let table = Resources["SearchFunctions"].SearchModelEntities(params);

for(var a=0;a<table.length;a++)

{

If(table[a].parentType/parentName="Mashup")

Mashups[table[a].name].RemoveTags({
tags: "ABC:Test" /* TAGS */
});

else if (table[a].parentType/parentName="Thing")

{

Things[table[a].name].RemoveTags({
tags: "ABC:Test" /* TAGS */
});

//for all the different parentType/Name

}

}