Skip to main content
1-Visitor
May 1, 2017
Solved

7.4 platform getID of organizations returning org name instead of ID

  • May 1, 2017
  • 10 replies
  • 6361 views

We are upgrading from an older version of thingworx in which our extension used the getID method for organizations to get their IDs. Now we are upgraded to, it returns the organization Name#Organization instead of the ID.

Original code:

Organization org = OrganizationManager.getInstance().getEntity(organizationName);

    return org.getID();

New 7.4 code:

   

Organization org = (Organization) EntityUtilities.findEntity(organizationName, ThingworxRelationshipTypes.Organization);

  return org.getID();

What can I change to get the organization ID in 7.4, or are IDs no longer supported in 7.4? I saw that the getID method is still available through the super but I cannot get it to return the ID.

Organization org = (Organization) EntityUtilities.findEntity(organizationName, ThingworxRelationshipTypes.Organization);

  _logger.debug(org.toString());

  return org.getID();

Best answer by posipova

As an update from the R&D, this works to Thingworx specs.

The id returned is dependent on the persistence provider being used. For the neo4j provider, the entity ids are a number converted to a string (e.g., "47"). For other providers the entity ids are of the form "<EntityName>#<EntityType>" (e.g., "Everyone#Organization").

Since you've been using neo4j in 6.0, and are now on a different persistence provider, this accounts for the perceived behavior difference.

10 replies

5-Regular Member
May 2, 2017

Camron could you please let us know from which version you have upgraded to ThingWorx 7.4? You are right could see the getID() still there

cjones-211-VisitorAuthor
1-Visitor
May 2, 2017

We were on 6.0.0-b542.

5-Regular Member
May 2, 2017

Cameron I have reported a Jira TW-19102 on this will keep you updated. Is it possible for you to open a support case in the meantime? if not I can do that for you.

posipova20-TurquoiseAnswer
20-Turquoise
May 8, 2017

As an update from the R&D, this works to Thingworx specs.

The id returned is dependent on the persistence provider being used. For the neo4j provider, the entity ids are a number converted to a string (e.g., "47"). For other providers the entity ids are of the form "<EntityName>#<EntityType>" (e.g., "Everyone#Organization").

Since you've been using neo4j in 6.0, and are now on a different persistence provider, this accounts for the perceived behavior difference.

cjones-211-VisitorAuthor
1-Visitor
May 8, 2017

Good to know, is there a way to access the original orgID's that were created in neo4j? We did switch from neo4J to postgres with the upgrade. Our datatable's use the orgID's in the name so that's how we look them up. We could change all of them to use the orgName#Organization instead, but that would be a largely manual process.

20-Turquoise
May 9, 2017

I don't think it is now possible with a different database, unfortunately. As getID wasn't ever intended to be used in such a way for organizations, and was rather a nuance of the neo db, this is not a feature that was taken care of or thought of when migrating to postgres.