var espacio="Proforma4";
var dest = companyhome.childByNamePath(espacio);
if (dest == null)
{
companyhome.createFolder(espacio);
}
for (var i = 0; i < bpm_package.children.length; i++)
{
var documento = bpm_package.children[i];
var mover = documento.move(dest);
if (mover == null)
{
var backupName = "Backup of " + mover.name;
mover.name = backupName;
mover.save();
mover.move(espacio);
}
}
El cual comprueba si existe un espacio var espacio="Proforma4";
var dest = companyhome.childByNamePath(espacio);
if (dest == null)
{
dest = companyhome.createFolder(espacio);
}
for (var i = 0; i < bpm_package.children.length; i++)
{
var documento = bpm_package.children[i];
var backupName = "Backup of " + documento.name;
if (dest.childByNamePath(documento.name) != null) {
//Falta determinar qué ocurre si ya existe en dest o en origen el nodo "Backup of X"
documento.name = backupName;
documento.save();
}
documento.move(dest);
}
Básicamente lo que no me parecía bien era el fragmento de:mover.name = backupName;
mover.save();
mover.move(espacio);
Ya que no deberían aplicarse sobre la variable mover (que es simplemente un indicador de si ha ido bien o no el movimiento del nodo). Debería hacerse contra documento.
<task-node name="Vendedor">
<task name="wfj:prueba" swimlane="initiator">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{bpm_assignee}</actor>
</assignment>
</task>
<transition to="Documentos Proformas" name="Enviar a Proforma">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var espacio="Proforma4";
var dest = companyhome.childByNamePath(espacio);
if (dest == null)
{
companyhome.createFolder(espacio);
}
for (var i = 0; i < bpm_package.children.length; i++)
{
var text=espacio + "/"+ bpm_package.children[i].name;
var logFile = companyhome.childByNamePath(text);
if (logFile == null)
{
bpm_package.children[i].move(dest);
}
else
{
var x=1;
var rr=0;
while(rr!=1)
{
var backupName2 = x + "-" + bpm_package.children[i].name;
var text2=espacio + "/"+ backupName2;
var logFile2 = companyhome.childByNamePath(text2);
if (logFile2 == null)
{
bpm_package.children[i].name= backupName2;
bpm_package.children[i].move(dest);
rr=1;
}
logFile = companyhome.childByNamePath(text2);
x=x+1;
}
}
}
</script>
</action>
</transition>
<transition to="OC Rechazadas" name="Rechazar"></transition>
</task-node>
<task-node name="Vendedor">
<task name="wfj:prueba" swimlane="initiator">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<actor>#{bpm_assignee}</actor>
</assignment>
</task>
<transition to="Documentos Proformas" name="Enviar a Proforma">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var espacio="Proforma4";
var dest = companyhome.childByNamePath(espacio);
if (dest == null)
{
companyhome.createFolder(espacio);
}
for (var i = 0; i < bpm_package.children.length; i++)
{
var text=espacio + "/"+ bpm_package.children[i].name;
var logFile = companyhome.childByNamePath(text);
if (logFile == null)
{
bpm_package.children[i].move(dest);
}
else
{
var x=1;
var rr=0;
while(rr!=1)
{
var documento =bpm_package.children[i];
var backupName2 = x + "-" + documento.name;
var text2=espacio + "/"+ backupName2;
var logFile2 = companyhome.childByNamePath(text2);
if (logFile2 == null)
{
documento.name= backupName2;
documento.save();
documento.move(dest);
rr=1;
}
logFile = companyhome.childByNamePath(text2);
x=x+1;
}
}
}
</script>
</action>
</transition>
<transition to="OC Rechazadas" name="Rechazar"></transition>
</task-node>
for (var i = 0; i < bpm_package.children.length; i++)
{
var text=espacio + "/"+ bpm_package.children[i].name;
var logFile = companyhome.childByNamePath(text);
if (logFile == null)
{
bpm_package.children[i].move(dest);
}
else
{
var x=1;
var rr=0;
while(rr!=1)
{
var backupName2 = x + "-" + bpm_package.children[i].name;
var text2=espacio + "/"+ backupName2;
var logFile2 = companyhome.childByNamePath(text2);
if (logFile2 == null)
{
bpm_package.children[i].name= backupName2;
bpm_package.children[i].move(dest);
rr=1;
}
x=x+1;
}
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
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.