Scenario:
I have to move Hellp.txt from Draft folder to Approved folder. First time it is working properly and sitting in the Approved folder but second time if i am trying move the updated same document second time then it is giving the following exception
org.alfresco.service.cmr.repository.DuplicateChildNodeNameException.
in this scenario, document name is same so it is giving this exception so we have to identify whether the approved folder has this document. if yes then delete that document and move the updated document else directly move the document to Approved folder.
if any web script available, please share with me.
Thanks in advance.
Regards,
Muqthar
Solved! Go to Solution.
This is easily scripted. You should look at the Alfresco JavaScript API. In particular, you will probably want to look at the getChildByNamePath function on ScriptNode.
Try that out and let us know if you get stuck.
This is easily scripted. You should look at the Alfresco JavaScript API. In particular, you will probably want to look at the getChildByNamePath function on ScriptNode.
Try that out and let us know if you get stuck.
Dear Jeff,
Thanks for your swift response.
We have written javascript and added as a rule (execute script) but the main problem is,
Move function is executing before our script so getting the same exception.
It will be helpful, if you provide any other alternate approach to achieve this.
Thanks in advance.
One more thought,
Can we use any existing aspects to achieve this?
Can anybody help me with this issue. Not able to move the document second time.
Are you talking about the Move action in the UI?
If that is the case, you can simply replace that by the move function using the javascript API.
Change the order with the existence check, and if everything is ok, then execute the move by code.
Something like:
if (document.properties["esc:semana"] &&
document.properties["esc:ano"]) {
var ano = document.properties["esc:ano"];
var semana = document.properties["esc:semana"];
var site = siteService.getSite(document.siteShortName);
var doclib = site.getContainer("documentLibrary");
var pastaAno = doclib.childByNamePath(ano);
if (!pastaAno) {
pastaAno = doclib.createFolder(ano);
}
var pastaSemana = pastaAno.childByNamePath(semana);
if (!pastaSemana) {
pastaSemana = pastaAno.createFolder(semana);
}
document.move(pastaSemana);
}
Notice that I am using both childByNamePath and move functions in the piece of code.
I hope you find this useful for your case.
What do you mean by existing aspects?
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.