I got an error when trying to update the content for an existing document that's managed by Ivy.wf().documents(). This api doesn't have the method update so I just tried with following code:

ivy.wf.documents().add("newfolder\\hello.pdf").write().withContentFrom(new File("sourcefolder\\file2.pdf", false));

The message looks like:

IOException: File newfolder\hello.pdf already exists PersistencyException: Cannot create file 'D:\work\AxonIvyDesigner6.3.0\files\application\newfolder\hello.pdf' for document 'newfolder\hello.pdf'

Yeah! it's correct! But, I want to update this existing file with new content.

I already tried to use method delete first:

ivy.wf.documents().delete(new ch.ivyteam.ivy.workflow.document.Path("newfolder\\hello.pdf"));

Or, trying to delete the physical file; but it did not work.

Thanks for your checking!

asked 22.10.2016 at 11:06

nvhuong's gravatar image

nvhuong
(suspended)
accept rate: 66%


Update of a existing document should work with:

ivy.wf.documents().get(new Path("/test")).write().withContentFrom(in.file);
link

answered 24.10.2016 at 17:24

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

Thank you. It works. I think it was just because I made a mistake with the string of path. it should be "newfolder/hello.pdf" rather than "newfolder\hello.pdf"

(27.10.2016 at 07:03) nvhuong nvhuong's gravatar image

I agree that the update methods are missing. However you get an existing document with the workflowDocument API and update it with the ch.ivyteam.ivy.scripting.objects.File api:

private static void update(IDocument document) throws IOException {
    Path path = document.getPath();
    ch.ivyteam.ivy.scripting.objects.File myFile = 
            new ch.ivyteam.ivy.scripting.objects.File(path.toString());
    myFile.write("new content "+new Date());
}
link

answered 24.10.2016 at 10:18

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

Thank you! I got it.

(27.10.2016 at 07:17) nvhuong nvhuong's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×147
×4

Asked: 22.10.2016 at 11:06

Seen: 4,758 times

Last updated: 27.10.2016 at 07:17