2 Replies Latest reply on Apr 21, 2017 5:41 AM by albertoz RSS

    Create template by snippet

    albertoz Explorer

      Hi, i need to create a template by snippet.

      I figured out this method but i can't see on the template list my new template and if i try to recreate it i receive the message "can't create template 'MyCustomNameTemplate' template already exist", i had this problem when i tryed to create a thing but i didn't restart it and enable it. Is there any similar method for templates ?


      var paramsRemoteThing = {

          name: "MyCustomNameTemplate",

          description: "my personal description",

          thingTemplateName: 'RemoteThing',

          tags: 'MyApp:Template'





      //here i need some code for enable template and see it in the template's list.


      thank you !!!

        • Re: Create template by snippet
          aanjan Heavyweight Champ

          Alberto, was that snippet part of a service that failed? If it says 'template already exists' and you can't see it, you've essentially created a ghost entity; that's an entity that exists in memory but is not committed to the database. You would always need to use a try-catch block around create scripts so that you avoid creating ghost entities.


          If you have ThingWorx 7.2.0+, please take a look at our Ghost Entities Cleaner extension in our Marketplace. Here is a KCS article that expands on the topic of detection, prevention and removal of said entities. With that being said, the create code you provided should work (on its own).