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

Correct strategy for creating simple services?

leisel
1-Newbie

Correct strategy for creating simple services?

I wanted to practice creating services to get a better understanding of what type of things I could do with services for my project. The services I imagine myself needing should not end up being too complex, but as of now I'm hung up on a couple of things.

Unfortunately I am not able to take a Fundamentals Course and am limited to the resources found through elearning.

Idea

The actual thing I wanted this service to do seemed pretty simple:

I'd have a list of things(they share the same template)

I'd select a row, and then push a button to run my service.

The service would take(as the input) the name of the selected row(the thing's name), and find out a specific property value of that thing to be output to a 'value display' widget.

therefore in the future i would know I could change values, or compare them etc.. I just wanted to do this to prove I could access the correct info.

Creating

I'm guessing the problem is knowing the correct way to start. This was my process:

I created this service on the template of the things I am interested in(not sure if this is a good strategy?)

The code was simple, just for finding out the string value of a Thing's property:

var params = {

  propertyName: StringName /* STRING */

};

// result: STRING

var result = me.GetStringPropertyValue(params);

To test it I checked the Services of one of these Things that implemented this template, and I clicked the 'Test' button.

I entered the input, which is just any String property that has a string value, and it correctly returned the string value of that property.

Mashup Implementation

The way I envisioned it above for my Mashup was a different story.

I have a list of the implemented things,

for the Selected Row, I chose the same string property that I entered for testing, and dragged it to the service's input parameter.

I used a button to act as the event that would trigger the service and have the 'result' display on a value display widget.

One strange thing about any self-created services from a ThingTemplate, is that i can only ever select them by adding the Template entity as Dynamic(the small checkbox to the right while adding an entity.) And doing so requires an extra input directly under the newly added entity. It's called 'Entity Name'

I assumed it would need the name of one of it's implemented things, the one who would be using it's service, so i chose the 'name' from Selected Rows to be the input for Entity Name.

This method never worked, and not having an Entity Name input never worked as well. The only info I've seen on this is posted here Made a template, added a service to it. Service is 'Dynamic' - why? and doesn't exactly solve my problem.

Is there a simpler way of creating a non-complex service like this? or am I doing anything incorrectly? is there a better way of thinking about a simple thing like this?

Thank you in advance.

5 REPLIES 5
PaiChung
22-Sapphire I
(To:leisel)

I believe everyone from the Academic program has access to Precision LMS and can take the Thingworx Fundamentals course.

I recommend you find if you can't find it and take the course.

I would find this by logging in here https://precisionlms.ptc.com/app/pages/Login/ correct?

If so neither myself nor my teammates are able to log into this for some reason. We've been learning through similar sites like the Learning Exchange.

I could probably contact the people who are overseeing our project to find out if we should be able to, or if they have a registration activation code.

Thank You

PaiChung
22-Sapphire I
(To:leisel)

Yes please check with the folks that run the Academic program.

vmihai
1-Newbie
(To:leisel)

Hi Levi,

Can you please send us an email at this address iot-academicsupport@ptc.com  telling us what problems you are having in accessing the plms trainings ?

Thank you,

Veronica

wposner-2
12-Amethyst
(To:leisel)

Hi Levi...

The reason you were not able to directly access your service unless you checked the dynamic box is that template and thing shape services are meant to be accessed directly from an thing which implements your template and/or thing shape.  If you first create a thing that implements your template and then add that thing to your mashup, you'll be able to directly access your service. 

On a side note--This is supposed to be a developer community where people can ask questions and get answers.  The previous suggestion of taking a course does NOT answer the original question.  And there definitely seems to be a pattern of these types of responses proliferated throughout this forum. 

Top Tags