Skip to main content
6-Contributor
August 30, 2021
Solved

Set Tag for Media Entities from a Service in for loop

  • August 30, 2021
  • 2 replies
  • 1259 views

I have a list of entities prepared in an infotable. Looks like "Things[entityname].SetTags(params);" this code works only for things but not for media and style definition entities. Please help.

 

 

try
{

var selectedTags = INFOTABLE; \\(list of entities);

var tableLength = selectedTags.rows.length;
for (var x = 0; x < tableLength; x++) {
var row = selectedTags.rows[x];

var tags = new Array();
var params = {
tags: "TagName:Voc"
};

var entityname = row.name;
Things[entityname].SetTags(params);

}
}
catch(err) {
logger.error("Error @ Thing -"+me.name+", Myservice, @ line " + err.lineNumber + ": " + err);
}

Best answer by ShirishMorkhade_238755

Hello @DM_9985019 ,

I personally haven't tried this, but for Media entity and Style Definition, can you please below two:

MediaEntities[entityname].SetTags(params);
and
StyleDefinitions[entityname].SetTags(params);

 

Thanks,

Shirish

2 replies

22-Sapphire I
August 30, 2021

Media entities most likely (I haven't tried) do not support services, so to get tags on a Media entity, you probably need to rewrite the full definition.

I don't recall there to be a specific service to just add tags to a Media entity.

16-Pearl
August 31, 2021

Hello @DM_9985019 ,

I personally haven't tried this, but for Media entity and Style Definition, can you please below two:

MediaEntities[entityname].SetTags(params);
and
StyleDefinitions[entityname].SetTags(params);

 

Thanks,

Shirish

Community Manager
September 10, 2021

Hi @DM_9985019.

 

If either of the previous responses allowed you to find a solution, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon