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

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

Get Entities based on Organizations

pshashipreetham
18-Opal

Get Entities based on Organizations

Hi,

 

Is there a way to get all the Entities based on an 'XYZ' Organization assigned to it?

 

Thanks,

 

Shashi Preetham,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.
ACCEPTED SOLUTION

Accepted Solutions

Hi Shashi,

 

Firstly, my apologies for the delay in reply.

 

Does your client use a single Project or small set of Projects to organize their Entities? If so, I believe I have come up with an effective solution. Please see the attached PTC.TS.UpdateOrgVisibility.Thing.It includes a Service called UpdateVisibilityPermissionsByProject. This service accepts the Source Organization, Destination Organization and a list of Projects to search for the Entities on. There are some caveats to mention with this approach:

  • Currently UpdateVisibilityPermissionsByProject accepts a list of Projects
    • It could easily be updated to fetch all Projects but this may not be necessary depending how the Entities that need to be updated are organized
  • There may be a performance impact on the Platform while this is running
  • It may take several seconds to complete depending on how many Entities need to be updated
    • ScriptTimeout in platform-settings.json may need to be increased to accommodate this long running operation
    • If the operation is taking an extended period of time you could try setting the Service to async
  • This code is provided "as is"
    • Recommended to execute this in a development instance that has a similar impacted Entity count to Production
    • Doing so will help to understand the expected timings and potential impacts

 

If this is not feasible because of the potential performance impact or the Entities are strung across too many Projects you may be able to do a full export of all Entities in the system to an XML file using the Import/Export > Export option. Whether or not this is possible depends on two things:

  • How many Entities are on this system?
    • If there are thousands of Entities it may not be possible to generate an XML export for the entire system or the export may be too large to work with in a text editor
  • Does the Organization name appear in any of the Services or Mashups?
    • You will ultimately do a Find & Replace with the XML export, replacing the old Organization name with the new Organization name
    • Given this, if the Organization name appears in other parts of the code or in Mashups replacing this value may have unintended side effects.

 

Hopefully this helps.

View solution in original post

6 REPLIES 6

Hello Shashi,

The answer depends on why you need to do that. For example

  1. If you need to check the entities to which your own user's organization has access to, then just do a Resources["SearchFunctions"].SearchThings(), or a wider SpotlightSearch. You will only see what you are allowed to see.
  2. If you are Administrator, and want to check to which org a Thing belongs to, you can iterate over all things in the system and do Things[name].GetVisibilityPermissions() to check the org.
  3. If you do it for some security purposes, e.g. want to check overall visibility, then it becomes much harder, because then you need to account for the visibility inheritance through Collections, ThingTemplates, etc.

/ Constantine

Hi, 

 

@Constantine Thanks for the response. After some time, research, and everything else, I learned that we don't have any workaround. As of now, there is no solution.

 

Thanks, 

Shashi Preetham,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.

Hi Shashi,

 

I'm curious to learn more about your use case to see if we can come up with a solution. Do any of the use cases proposed by Constantine match what you are trying to do? If so, please help me by confirming which scenario and why the proposed solution may not work. If none of the solutions match, please provide some further details about what you are looking to accomplish and I will be happy to look into it further.

Hi @tmisner ,

 

The Organisation created in Thingworx is used for the Formlogin. After a couple of years, the Client wants a rename, which makes it impossible to edit the Organisation.

Hundreds of entities have been created, and the Organisation was assigned permissions; now we can't edit them manually one by one.

 

Therefore, I was looking for a way to get all the entities associated with the Organisation.

Shashi Preetham,
Email: psp316r@outlook.com,
Mobile: +91 8099838001.

Hi Shashi,

 

Firstly, my apologies for the delay in reply.

 

Does your client use a single Project or small set of Projects to organize their Entities? If so, I believe I have come up with an effective solution. Please see the attached PTC.TS.UpdateOrgVisibility.Thing.It includes a Service called UpdateVisibilityPermissionsByProject. This service accepts the Source Organization, Destination Organization and a list of Projects to search for the Entities on. There are some caveats to mention with this approach:

  • Currently UpdateVisibilityPermissionsByProject accepts a list of Projects
    • It could easily be updated to fetch all Projects but this may not be necessary depending how the Entities that need to be updated are organized
  • There may be a performance impact on the Platform while this is running
  • It may take several seconds to complete depending on how many Entities need to be updated
    • ScriptTimeout in platform-settings.json may need to be increased to accommodate this long running operation
    • If the operation is taking an extended period of time you could try setting the Service to async
  • This code is provided "as is"
    • Recommended to execute this in a development instance that has a similar impacted Entity count to Production
    • Doing so will help to understand the expected timings and potential impacts

 

If this is not feasible because of the potential performance impact or the Entities are strung across too many Projects you may be able to do a full export of all Entities in the system to an XML file using the Import/Export > Export option. Whether or not this is possible depends on two things:

  • How many Entities are on this system?
    • If there are thousands of Entities it may not be possible to generate an XML export for the entire system or the export may be too large to work with in a text editor
  • Does the Organization name appear in any of the Services or Mashups?
    • You will ultimately do a Find & Replace with the XML export, replacing the old Organization name with the new Organization name
    • Given this, if the Organization name appears in other parts of the code or in Mashups replacing this value may have unintended side effects.

 

Hopefully this helps.

Hi @pshashipreetham 

 

Did you find the last response on this post helpful?  If so, please mark it as the Accepted Solution for the benefit of others in the community.  If you still have questions, please let us know.

 

Regards.

 

--Sharon

Announcements


Top Tags