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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

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

jacekgra
1-Newbie

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

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6
PaiChung
22-Sapphire I
(To:jacekgra)

Each Entity carries isSystemObject

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

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);

        }

    }

}

Hello Sajid,

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

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

Thank you Carlos! It works as expected.

Yes, just realized that it is a customized resource. Anyways, Carles's answer is more generic.

Top Tags