Delete Document using automation chain which is called in event documentCreated

I am trying to create an automation chain which is called on the event 'documentCreated' and newly uploaded document is saved as attachment on another document. But after attaching, this newly uploaded document is also created as new document. I want to avoid that. I want to delete that newly created document.

Can anyone help me with this? I tired to use operation document.delete(), but entire chain is rolled back because I'm calling it in documentCreated.

So what should I do to delete newly created document? Which event handler should I use?

Thanks in advance.

0 votes

0 answers



What do you mean by "newly uploaded document is saved as attachment on another document." It sounds like you are uploading a binary to save as an attached file on an existing Nuxeo document. Could you give us more information on what you're trying to accomplish?

My requirement is that,

There are multiple versions of a document and they are uploaded at different times.

I found a way to check conditions for above and add documents as multiple versions of the document (attach new document to old document as new version).

I did this using automation chain and its called on event document created.

But while I'm running this chain, a document is also created with it. I want to avoid or delete that uploaded document.

I tried using document.delete() in the chain, but complete operation is failed and all the changes made using automation chain is rolled back. . . . . Can you help me to find a solution for this?

Thank you so much for replying.


Thanks for the further explanation. I'm still not clear on how you are attaching documents to documents. Are they relations? Or are you uploading file documents? Could you post the automation chain here? Maybe you should use documentModified instead of created.

But I'm using Create Version operation in the chain. So chain can't be called in document modified right?

In Chain, while uploading a document, i'm checking for similar file name and if found a document with same file name then Blob.AttachOnDocument is called to attach to old document as main content with updated version.