Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
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();
Solved! Go to Solution.
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.
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
We were on 6.0.0-b542.
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.
I opened a support case. Thanks, I saw someone posted (then deleted) that there is no organizationID in 7.x is that true?
I've taken the ownership of your case. I do have a vague memory of this becoming obsolete, however, I am trying to confirm that right now.
Awesome thanks, I did see that the organizations still have a ID property but it is just the "organizationName#Organization" now instead of the organizationID like previously.
For the completion sake here's the link to the public knowledge base article filed for tracking this issue and the Jira filed for it https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS261848&lang=en_US
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.
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.
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.