How to retrieve/delete by GUID in Java?

0
Hi, we want to take care of duplicates floating around in the system as logged in Application.log by M2EE What is the general way of retrieving IMendixObjects by guid [with no module.entity name having to be specified]? The best I can come up with is this:   function getByGuid(guid){ var ret=null; var rs=com.mendix.core.Core.createRetrievalSchema(); var mi=com.mendix.core.Core.createMendixIdentifier(guid); try{ var str_xpath="//"+mi.getObjectType()+"[id='"+guid+"']"; var arr_obj=com.mendix.core.Core.retrieveXPathQuery( root.getContext(), str_xpath ); if(arr_obj.length>0){ ret=arr_obj[0]; } }catch(e){ ret=null; } return ret; } var arr_guid=[ '00000000000000001', // -------------------------- '00000000000000002', // Constructed from logs .... '00000000000000003' // -------------------------- ]; var arr_obj=[]; for(var i=0;i<arr_guid.length;i++){ var obj=getByGuid(arr_guid[i]); if(obj!=null){ arr_obj.push(obj); } } com.mendix.core.Core.delete(root.getContext(),arr_obj);  
asked
1 answers
2

Hello Ockert,

Have you tried:

Core.createMendixIdentifier(identifier).getObject()

Hope this helps

answered