Use case: I have a Part Structure. I want to add all the Parts and associated EPMDocuments available in the structure, Add the structure into the workspace and then do check out all the EPMDocuments from the workspace.
What i did :
private void checkoutDocument(EPMDocument document) throws WTException, WTPropertyVetoException {
try {
System.out.println("Checking out document: " + document.getNumber());
if (!WorkInProgressHelper.isCheckedOut(document)) {
// Get the current user's checkout folder
Folder checkoutFolder = WorkInProgressHelper.service.getCheckoutFolder();
// CheckoutLink chilink = WorkInProgressHelper.service.checkout(document, checkoutFolder, "Check out comment");
CheckoutLink chilink = WorkInProgressHelper.service.checkout(document, checkoutFolder, WorkspaceName)
wt.epm.EPMDocument wrk = (wt.epm.EPMDocument)chilink.getWorkingCopy();
System.out.println("Document checked out successfully: " + wrk.getIdentity());
} else {
System.out.println("Document is already checked out.");
}
} catch (WTException e) {
e.printStackTrace();
throw new WTException("Error checking out document: " + e.getMessage());
}
}
Solved! Go to Solution.
I got the answer, insted of using
CheckoutLink chilink = WorkInProgressHelper.service.checkout(document, checkoutFolder, WorkspaceName);
I used : CheckoutLink chlink = WorkInProgressHelper.service.checkout(document, workpace.getfolder(), "comment");
EPMDocument wrk = (wt.epm.EPMDocument) chlink.getWorkingCopy();
I added all things into workspace, i did checkout also, but in the workspace it was showing. checkout by you added into some other workspace.
Can you share your log messages? I can assume you used the same workspace name for adding and checkout? Can you also hover over that workspace status icon you highlighted? Also, check the history on one of those objects. It should show you where the working copy is checked out to.
I attached the MSlogs file,
i am doing the checkout after the EPPM Document get added into the workspace, i highlighted the workspace number, in the MSLog also it sysout was showing the same workspace id:
I think it was doing the checkout from the windchill side, we need to do it from the workspace side, do you have any sample code for doing checkout the object from the workspace.
I got the answer, insted of using
CheckoutLink chilink = WorkInProgressHelper.service.checkout(document, checkoutFolder, WorkspaceName);
I used : CheckoutLink chlink = WorkInProgressHelper.service.checkout(document, workpace.getfolder(), "comment");
EPMDocument wrk = (wt.epm.EPMDocument) chlink.getWorkingCopy();