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.
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.