03-04-2017 12:07 PM
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
03-05-2017 04:35 PM
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.
03-05-2017 04:35 PM
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.
03-06-2017 04:22 AM
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.
03-07-2017 02:12 PM
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.
03-06-2017 04:28 AM
One more thought,
Can we use any existing aspects to achieve this?
03-08-2017 02:08 PM
What do you mean by existing aspects?
03-07-2017 09:08 AM
Can anybody help me with this issue. Not able to move the document second time.
Explore our Alfresco products with the links below. Use labels to filter content by product module.