Mx 7 convert long to MendixIdentifier.

0
What i would like to do is retrieve an object based on its entity(type) and on a long value. How can i convert the provided long value to a MxIdentifier, so that i can use the Core.retrieveId?
asked
2 answers
3

This should be the right one

IMendixIdentifier Core.createMendixIdentifier(longĀ guid)

 

answered
1

I've used the CommunityCommons XPath functions for this, see the Java code below:

 

import communitycommons.XPath;

private IMendixObject retrieveObject(String objectType, String objectGUID) throws CoreException {
	final String attributeID = "id"; 
	final String operator = "=";
	IContext systemContext = Core.createSystemContext();
	//Create XPath 
	XPath<IMendixObject> xpath = XPath.create(systemContext, objectType);
	xpath.compare(attributeID, operator, objectGUID);
	xpath.first();
	//Execute XPath
	List<IMendixObject> results = Core.retrieveXPathQuery(getContext(), xpath.getXPath());
	if (results.size() == 0) {
		logger.error("Object with GUID " + objectGUID + " was not found.");
		return null;
	}
	return results.get(0);
}

 

answered