Skip to main content
1-Visitor
July 13, 2016
Solved

List of all System Objects in order to set permissions in a batch (script)

  • July 13, 2016
  • 6 replies
  • 3774 views

Is there any way to obtain list of all SystemObjects that exists in Thingworx?

I would like to set specific permissions on all SystemObjects and I definetlly don't want to do it manually

Best answer by CarlesColl

Hi Jacek,

Maybe better you go with this service ( which should be faster than previous one 😞

var result = Resources["SearchFunctions"].SpotlightSearch({

  maxItems: 1000000 ,

  types: { items: ["Thing",

                     "ThingShape",

                     "ThingTemplate",

                     "DataShape",

                     "Network",

                     "ModelTagVocabulary",

                     "Mashup",

                     "Menu",

                     "MediaEntity",

                     "StyleDefinition",

                     "StateDefinition",

                     "DataTagVocabulary",

                     "Group",

                     "User",

                     "ApplicationKey",

                     "Resource",

                     "Organization",

                     "Dashboard"

                    ]},

  aspects: { isSystemObject: true },

  maxSearchItems: 1000000

});

for each (row in result.rows) {

    // -- Do Whatever the the row.name entity

}

Pai Chung​ Can you update this article https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS241962 with the above code, I think it's better.

Best Regards,

Carles

6 replies

22-Sapphire I
July 13, 2016

Each Entity carries isSystemObject

You might be able to leverage one of the SearchFunctions and use that Property in conjunction.

12-Amethyst
July 13, 2016

This snippet might help:

var types = Resources["Tagger"].GetEntityTypes();

for (var x = 0; x < types.rows.length; x++) {

    var row = types.rows;

    var entities = Resources["EntityServices"].GetEntityList({type: row.name});

    for (var y = 0; y < entities.rows.length; y++) {   

        var entity = entities.rows;

        if (entity.isSystemObject) {

            logger.info("System object : " + entity.name);

                      // Do whatever here

        } else {

            logger.info("Not a system object : " + entity.name);

        }

    }

}

jacekgra1-VisitorAuthor
1-Visitor
July 14, 2016

Hello Sajid,

Unfortunatelly I do not have resource "Tagger" in my TWX 7.1. Is this something from older version or customization?

1-Visitor
July 14, 2016

Hi Jacek,

Maybe better you go with this service ( which should be faster than previous one 😞

var result = Resources["SearchFunctions"].SpotlightSearch({

  maxItems: 1000000 ,

  types: { items: ["Thing",

                     "ThingShape",

                     "ThingTemplate",

                     "DataShape",

                     "Network",

                     "ModelTagVocabulary",

                     "Mashup",

                     "Menu",

                     "MediaEntity",

                     "StyleDefinition",

                     "StateDefinition",

                     "DataTagVocabulary",

                     "Group",

                     "User",

                     "ApplicationKey",

                     "Resource",

                     "Organization",

                     "Dashboard"

                    ]},

  aspects: { isSystemObject: true },

  maxSearchItems: 1000000

});

for each (row in result.rows) {

    // -- Do Whatever the the row.name entity

}

Pai Chung​ Can you update this article https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS241962 with the above code, I think it's better.

Best Regards,

Carles