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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Updating only Model tags with some custom service.

RK_0705
11-Garnet

Updating only Model tags with some custom service.

Hi Team,

 

Suppose I have a set of entities under some project and I want to change the model tags of of all the entities under that project with some custom service (without changing the vocabulary terms), what would be the snippet for this custom service?

 

Thanks in advance.

6 REPLIES 6
abjain
13-Aquamarine
(To:RK_0705)

RK_0705
11-Garnet
(To:abjain)

@abjain 

Actually what happens, all the entities are having different types like Mashups, Things, ThingTemplates etc so I am not able to write a single generic syntax in one code with passing input runtime entity type.

 

Actually I want to access these services with input as dynamic group type just like :-

[EntityType][row.name].AddTags();

 

where input is EntityType.

 

What would be the actual syntax for this scenario.

 

Just like.... Things[ThingName].AddTags()  //default one

 

Please advise.

abjain
13-Aquamarine
(To:RK_0705)

@RK_0705 : For each entity you will have then have to find its corresponding base type. For this you can utilize the service 'SearchModelEntities' in SearchFunctions resource. Attaching sample screenshot for its usage. After getting the type, in your service there should be conditional statements(like if/else) for each type where you can call the addatgs for specific type.

Ex:

if (entitytype=='Thing')

{

Things[Enityname].AddTags() ;

}

else if(entitytype=='Mashup')

{

Mashups[Enityname].AddTags() ;

}

and so on....

abjain_0-1624268379187.png

 

 

RK_0705
11-Garnet
(To:abjain)

@abjain 

I already have the type column with me using GetEntities service of Project.

 

This is the reason I asked this question because I don't want to write this AddTags, Remove Tags in every if statement.

 

I just want to get 'type group' from 'type' ("Things" from type "Thing")

and then assign it into one variable like "groupName" and gets automatically replaced dynamically with the respective 'type group' like Things, Datashapes,ThingTemplates etc in below syntax:-

 

[groupName][row.name].AddTags();

abjain
13-Aquamarine
(To:RK_0705)

@RK_0705 I tried this on my end and checked if we can use a variable to refer to different types in the syntax while adding tags for particular entity. Actually in services we refer to any entity by specifying its type like Things[thingname] or Mashups[name]. Now we cannot do this here:

var groupname="Things"

groupname[thingname].addTags().

I tried different combination of syntax here but 'groupname' in above cannot be dynamic. I think you will have to use conditional statements to group different entities types. Do you see any particular challenge in this approach?

slangley
23-Emerald II
(To:RK_0705)

Hi @RK_0705

 

Please let me know if you have found a solution with the help of one of the previous responses.  If so, please mark the appropriate one as the Accepted Solution for the benefit of others with the same issue.

 

If you are still searching for a solution, please let us know.

 

Regards.

 

--Sharon

Top Tags