Create Document with WTDocument Subtype from Workflow Expression Robot
Hello everybody,
I have a problem with setting the document Type of a new created Document from a expression Robot Workflow. I managed to create a WTDocument but cant set the subtype type.
I found this article, but could not get it to work: https://community.ptc.com/t5/Windchill/How-to-create-subtype-of-WTDocument-by-API/td-p/482345
Thank you for your help.
String name = "Test1234566788"; // Name
String number = "12343455677"; // Number
String lifeCycleName = "LC_TEST"; // Lifecycle name
String container_path = "/wt.inf.container.OrgContainer=Test/wt.inf.library.WTLibrary=Test"; // The container where the document will be created/located
String folder_path = "/Default"; // Folder path
wt.doc.WTDocument doc = wt.doc.WTDocument.newWTDocument();
doc.setName(name);
doc.setNumber(number);
/// ----------- TESTAREA -------------------------------
doc.setDocType(wt.doc.DocumentType.toDocumentType("WCTYPE|wt.doc.WTDocument|de.test.TESTDocument"));
/// ----------- TESTAREA -------------------------------
wt.inf.container.WTContainerRef containerRef = wt.inf.container.WTContainerHelper.service.getByPath(container_path);
doc.setContainerReference(containerRef);
wt.folder.Folder folder = wt.folder.FolderHelper.service.getFolder(folder_path,containerRef);
wt.folder.FolderHelper.assignLocation(doc, folder);
wt.lifecycle.LifeCycleTemplate lct = wt.lifecycle.LifeCycleHelper.service.getLifeCycleTemplate(lifeCycleName , doc.getContainerReference());
doc = (wt.doc.WTDocument) wt.lifecycle.LifeCycleHelper.setLifeCycle(doc, lct);
doc = (wt.doc.WTDocument) wt.fc.PersistenceHelper.manager.store(doc);

