ThingWorx Model Definition and Composer > Tags > Adding Tags Programmatically
  
Adding Tags Programmatically
Tags can be added and edited by using the SetTags() and AddTags() services.
SetTags
SetTags() can be used to set tags on an entity with no existing tags or to overwrite existing tags. If an entity already has tags, they will be overwritten with whatever is specified in the parameters of the SetTags() service.
Multiple tags can be added with an array:
var tags = new Array();
var params = {
tags : tags
};
// SetTags(tags:TAGS)
Things['ThingName'].SetTags(params);
Single tags can be added directly to the service parameters:
var params = {
tags : "Application:Tag1"
};
// SetTags(tags:TAGS)
Things['ThingName'].SetTags(params);
AddTags
AddTags() can be used to append new tags to an entity with existing tags. Multiple or single tags can be added to entities in the same way that they are added using SetTags().
var params = {
tags : "Application:Tag1"
};
// AddTags(tags:TAGS)
Things['ThingName'].AddTags(params);
Related Links
Tags