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
Can I create a document using the program from the object in the attachment table?
Solved! Go to Solution.
Hi @avillanueva
Iam sure that he is looking for a code to do so 😄
@smcvr Here is a code how to add/update primary content
CS237668 - How to update Primary Content
PS: fileStream can be any InputStream. So the "file" does not have to be on a disk but it can be just in memory.
for example
I use a findContentStream to read a AppData
InputStream is = ContentServerHelper.service.findContentStream(appData);
PetrH
Need more info here? Are you talking about uploading code to attachments of a document and then having Windchill execute that? The security part of my brain is having a fit. Please elaborate.
Hi @avillanueva,
No, I want to attach the document added by users in the Problem Report process to the Attachment table of another incoming document as Primary Content. For example, when a user initiates Problem Report number 1213, I create a general document before the task is assigned to the user. When the task is assigned to the user, they will upload the document to the attachment table under the problem report, and I want to add this document as Primary Content in the general document.
Yes, this can be done via a expression robot at the beginning of your Problem Report workflow. Recommend creating an external class with a static method that passes in the PBO, in this case the Problem Report. Assumption here is that the user uploads a file during the creation of a problem report that you want to take action on.
You'll need the following bit of code:
Recommend also that you keep track of results in case you want to pass those back to the workflow to make routing decisions in case of error or bad input.
Hi @avillanueva
Iam sure that he is looking for a code to do so 😄
@smcvr Here is a code how to add/update primary content
CS237668 - How to update Primary Content
PS: fileStream can be any InputStream. So the "file" does not have to be on a disk but it can be just in memory.
for example
I use a findContentStream to read a AppData
InputStream is = ContentServerHelper.service.findContentStream(appData);
PetrH
Hi @HelesicPetr ,
Thank you for your response.
I started creating the code. I am trying to create a new document in the flow and load the document in the attachment table into that document. But there was an error in my code and I couldn't solve it.
CODE:
DataFormatReference newdfr = getDataFormat(appData.getBusinessType());
ERROR:
WfExpression_2287132672.java:122: error: cannot find symbol
wt.content.DataFormatReference newdfr = getDataFormat(appData.getBusinessType());
^
symbol: method getDataFormat(String)
location: class WfExpression_2287132672
Note: WfExpression_2287132672.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: WfExpression_2287132672.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Hi
Also recommend that before deploying in production, you take that code and move it to an external class. This way if you have a bug or need to make changes, you can do that without destroying an executing workflow. If you have too much code in the workflow expression robot itself, any issues will force you to start the workflow process all over again.
Agree with @avillanueva
If you use code to do something and you would change it, then the external code is easier to change and you do not involve the workflow.
If you need to change the code directly in the workflow, then you always need to start new workflow process and can not continue in already executed one.
PetrH