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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Service for Inserting a service into entities

muzzammil
11-Garnet

Service for Inserting a service into entities

How can i go for duplicating a service of a specific thing inside other entities like things or thing templates?

8 REPLIES 8
PaiChung
22-Sapphire I
(To:muzzammil)

I'm not sure why you need to duplicate a service.

You could just create a central helper Thing with services and then invoke that service from the other Entities.

Especially if it is doing the same evaluation.

Why not implement the shared service in a ThingShape and both entities will implement that shape?

@ashaban Thank you. I hope this will help me

ashaban
11-Garnet
(To:ashaban)

You might also like to try:

 

// result: INFOTABLE dataShape: "ServiceDefinition"
var result = ThingTemplates["YouThing"].GetServiceDefinition({
name: "serviceToCopy" /* STRING */
});

//see ServiceDefinition data shape for the below paramter inputs
ThingTemplates["OtherThing"].AddServiceDefinition({
name: undefined /* STRING */,
description: undefined /* STRING */,
remoteServiceName: undefined /* STRING */,
category: undefined /* STRING */,
remote: undefined /* BOOLEAN */,
parameters: undefined /* INFOTABLE */,
resultType: undefined /* INFOTABLE */,
timeout: undefined /* INTEGER */
});

Actually, i needed a help with a default service 'AddServiceDefinition()'. With this service i'm being able to insert a  service inside an entity, but being unable to insert a code in that inserted service. Can u help me on this?

I'm sorry but I'm not sure how or if it is even possible to "inject" code to a new Service.

The code can come from different places, from Jars or Composer Js and so on.

Please try the ThingShape approach and see if it can help you.

PaiChung
22-Sapphire I
(To:muzzammil)

This will only work with Remote Services, ie Services on a connected Thingworx Agent

it will not allow you to create new regular defined services.

 

@PaiChung Actually, with the available snippet, i'm being able to insert a service in the desired entity (like Thing or Thing Template) but being unable to insert a code into that service. So, this way i'm quite sure that there could be some way for inserting a code too. Kindly help me on this.

Top Tags