Skip to main content
11-Garnet
March 11, 2024
Question

How to retrieve all related objects from EPMDocument and to workspace

  • March 11, 2024
  • 1 reply
  • 742 views

Hello All,

How to retrieve all related objects from EPMDocument and to workspace?

Thanks.


@HelesicPetr 

1 reply

1-Visitor
March 13, 2024

@Pushpak wrote:

Hello All,

How to retrieve all related objects from EPMDocument and to workspace?

Thanks.


@HelesicPetrMyMilestoneCard


Hello,

 

To retrieve all related objects from an EPMDocument to a workspace in Windchill, you can use the Windchill Java API. Hereโ€™s a general approach using the API:

 

 

public static void retrieveRelatedObjects(EPMDocument epmDocument) throws WTException {
 // Get the master of the EPMDocument
 EPMDocumentMaster master = (EPMDocumentMaster) epmDocument.getMaster();
 
 // Use EPMStructureHelper service to navigate the 'describes' link to get related objects
 QueryResult relatedObjects = EPMStructureHelper.service.navigateDescribedBy(master, null, false);
 
 // Iterate through the related objects
 while (relatedObjects.hasMoreElements()) {
 Persistable relatedObject = (Persistable) relatedObjects.nextElement();
 
 // Check if the related object is an EPMDocument and add it to the workspace
 if (relatedObject instanceof EPMDocument) {
 EPMDocument relatedEPMDocument = (EPMDocument) relatedObject;
 // Add logic to add the relatedEPMDocument to the workspace
 }
 }
}

 

This code snippet demonstrates how to navigate the relationships of an EPMDocument to find related objects. You would need to add your own logic to add these objects to a workspace, possibly using EPMWorkspaceHelper.manager.addToWorkspace() method.

 

I hope this solution worked for you. 

 

Best regards,

Yvonne Rhodes