Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hey guys! I've got a query-objects webject doing a lookup for me, and then I'm taking the OBIDs of the returned objects and turning them into Java objects in my Java API... but I've got an issue -- when a webject returns a VR: obid, I can't resolve the reference because Windchill tells me "it no longer exists."
So what I'm looking for is a way to either look up the OR: obid that corresponds to the VR: obid I got from the webject, or some way to resolve the VR: obid to a java object somehow.
Any help is appreciated, thanks for your time!
-Tom
This question was asked quite some time back. I'm not sure it got resolved.
Is there a piece of code that will derive an OR from a VR?
Mant Thanks,
Derek
Hi Derek,
I think the following piece of code should be working:
public static String getORFromVR(String vr) throws WTException {
vr = vr.substring(0, vr.lastIndexOf(":"));
ReferenceFactory rf = new ReferenceFactory();
WTReference ref;
ref = rf.getReference(vr);
WTObject lct = (WTObject) ref.getObject();
ObjectReference objRef = ObjectReference.newObjectReference(lct);
return objRef.getKey().toString();
}
Kind Regards
Maciej Grodzki
Many Thanks for the reply, Maciej. I'll try it out.
Regards,
Derek
//When you have string value contains VR
WTReference ref = refFactory.getReference(oid);
//When you have obj
VersionReference versionReference = VersionReference.newVersionReference(partVersion);
businessObjRef = "VR:" + businessObjRef.replace('>',':');
Ayyappan
Ayyappan
Thanks for filling this in. Very helpful.
Regards,
Derek
Maciej/Ayyappan,
Thanks to both of you. This helps move things along.
Regards,
Derek