Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
I want a file to be created in the product when the user starts the workflow process. I prepared a code for this, but I could not proceed further because I received an error in the expression.
How can I perform such an operation in the workflow?
What are the errors in my code?
CODE:
try {
wt.org.WTPrincipal wtPrincipal = wt.session.SessionHelper.manager.getPrincipal();
wt.org.WTPrincipalReference principalReference = wt.org.WTPrincipalReference.newWTPrincipalReference(wtPrincipal);
// Assuming productId is defined somewhere in your code
wt.folder.Folder productFolder = wt.folder.Folder.newFolder();
productFolder = wt.pdmlink.PDMLinkProduct(productId);
wt.folder.Folder newFolder = wt.folder.Folder.create();
newFolder.setName(name);
newFolder.setDescription(folderDescription);
wt.folder.FolderHelper.service.addToFolder(productFolder, newFolder);
wt.fc.PersistenceHelper.manager.save(newFolder);
System.out.println("Folder created successfully under the product.");
} catch (Exception e) {
e.printStackTrace();
}
wt.inf.container.WTContainerRef containerRef = getContainerRefById(productId);
wt.query.QuerySpec querySpec = new wt.query.QuerySpec(wt.folder.Folder.class);
querySpec.appendSearchCondition(
new wt.query.SearchCondition(
wt.folder.Folder.class,
wt.folder.Folder.CONTAINER_REFERENCE + "." + wt.inf.container.WTContainerRef.KEY + "." + wt.inf.container.WTContainerRef.ID,
wt.query.SearchCondition.EQUAL,
containerRef.getId()
),
new int[]{0}
);
wt.fc.QueryResult queryResult = wt.fc.PersistenceHelper.manager.find(querySpec);
queryResult.nextElement();
wt.inf.container.WTContainerRef containerRef = wt.inf.container.WTContainerRef.newWTContainerRef(containerId);
Note: I defined the productId ande containerId value as a string and added Id.
ERROR:
Checking Syntax...
WfExpression_2287132672.java:97: error: cannot find symbol
wt.folder.Folder productFolder = wt.folder.Folder.newFolder();
^
symbol: method newFolder()
location: interface Folder
WfExpression_2287132672.java:98: error: cannot find symbol
productFolder = wt.pdmlink.PDMLinkProduct(productId);
^
symbol: class pdmlink
location: package wt
WfExpression_2287132672.java:100: error: cannot find symbol
wt.folder.Folder newFolder = wt.folder.Folder.create();
^
symbol: method create()
location: interface Folder
WfExpression_2287132672.java:101: error: cannot find symbol
newFolder.setName(name);
^
symbol: method setName(String)
location: variable newFolder of type Folder
WfExpression_2287132672.java:102: error: cannot find symbol
newFolder.setDescription(folderDescription);
^
symbol: variable folderDescription
location: class WfExpression_2287132672
WfExpression_2287132672.java:104: error: cannot find symbol
wt.folder.FolderHelper.service.addToFolder(productFolder, newFolder);
^
symbol: method addToFolder(Folder,Folder)
location: variable service of type FolderService
WfExpression_2287132672.java:111: error: cannot find symbol
wt.inf.container.WTContainerRef containerRef = getContainerRefById(productId);
^
symbol: method getContainerRefById(String)
location: class WfExpression_2287132672
WfExpression_2287132672.java:116: error: cannot find symbol
wt.folder.Folder.CONTAINER_REFERENCE + "." + wt.inf.container.WTContainerRef.KEY + "." + wt.inf.container.WTCon
Syntax check complete.
Solved! Go to Solution.
can you try with class wt.folder.SubFolder