Skip to main content
17-Peridot
April 28, 2023
Solved

Creating custom boilerplate snippets

  • April 28, 2023
  • 1 reply
  • 3354 views

Hello,

 

I want to preface this post with saying that I am not very good with Java, so please excuse any glaring rule breaking.

 

Anyway, I wanted to try and make some company specific boilerplate snippets.

I have managed to create a custom extension and I can import it into my platform correctly.

However when used, it returns a function like;

 

let ResultTypeName = doSomething();

 

Instead of what I am returning from the "doSomething" function.

 

I'm certain I am doing something wrong.

 

What I want is basically something similar to how the try/catch snippet works, or really almost any other snippet. 

 

I started with following this PTC article and also this document but felt it didn't really cover my needs.

So if anyone has any other resources around this, I'd very much appreciate it if they could post them here.

 

I'm also uploading my metadata and src file in case it is of interest.

 

Thanks,

Jens

Best answer by slangley

Hi @jensc.

 

We did more research on this and found that even if you're able to add snippets, only users in the Administrators group will be able to see them.

 

At this point in time, this is not a supported feature of ThingWorx and previous requests for this have not been approved.

 

Regards.

 

--Sharon

1 reply

Community Manager
May 4, 2023

Hi @jensc.

 

Since you're new to this, it would be recommended that you create a thing in Composer and add your services that way.  You can use export/import on the thing containing the code for transferring it to other environments.  This approach would allow you to become more familiar with the process prior to developing an extension.

 

Let us know if this works for getting it up and running.

 

Regards.

 

--Sharon

jensc17-PeridotAuthor
17-Peridot
May 5, 2023

Hello @slangley ,

 

I unfortunately don't think that that will do what I want.

 

Perhaps I have misunderstood the functionality of the "Script Function Library". I thought I would be able to create snippets similar to the out of the box ones. Ones like the Control flow snippets:

jensc_0-1683267175561.png

But perhaps it is just meant to create functions, which in hindsight makes sense I guess considering the name "Script 'Function' Library".

 

So I guess my first question is, am I way off?

 

Thanks,

Jens

Community Manager
May 12, 2023

Hi @jensc.

 

You won't be able to add to the built-in snippet library.  You can however create your own extension per the documentation you previously found.  These should provide the guidance needed for creating a custom extension containing your custom services which you can then reference via the thing.

 

Regards.

 

--Sharon