Hi,
I'm trying to create a JavaScript file that destroy files when possible. However, I'm not finding a way to do that since, aparently, doesn't exist a document.destroy.
Is there some especific function that does this?
You may use Alfresco JSConsole addon:
https://community.venzia.es/alfresco-javascript-console/
This tools includes a full reference of Alfresco Repository JavaScript API.
Anyway, I guess you are looking for document.remove() method.
Thanks for the answer, but when I try to execute the method document.remove(), I get the following message:
"09061538 Failed to execute script 'workspace://SpacesStore/58b89198-b52b-417c-a311-e9cc1c4f4fc3': Node does not exist: workspace://SpacesStore/60f67e94-6e73-42a2-8f3b-7eefc5e174f0 (statustatus[id=85115changeTxnId=0f6fd51b-248e-4cd8-b3d9-c1bcf4d43649, dbTxnId=13929, deleted=true])"
Besides that, the addon just make things easier when it comes to test the script, anyway, I don't have the possibility of installing an addon such as the JSConsole, so this option is unviable.
Probably you're trying to remove the document in the same DB Transaction you are creating it.
That operation is not supported, since every JS script runs in a single DB Transaction.
My document was already created before the script and the only change I'm making is switch a option on the metadata to trigger the script.
To exclusively test this, my code is only the method Document.remove(), I've already tried Document.parent.remove(), but both of them gives the same error.
I made a simple tests and document.remove() works as expected.
I guess the problem is related with the metadata updating, since the document is removed and after that Alfresco is trying to update that metadata property. May you try triggering removal by using some other method?
Or alternatively, provide the actual script that you are trying to execute, instead of just the single instruction. As well as the whole stacktrace that belongs to the error, not just the message. That way it'd be a lot easier to help pinpoint the cause of it.
I made some changes and the function worked, but thats not what I am looking for. The method document.remove() deletes the document, I want to destroy it, preservating the metadata of the file.
document.content = "";
My objective isn't erasing the content of my file, it is to use the destroy function of alfresco through JavaScript.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.