AnsweredAssumed Answered

Update tags of folder content: error in script execution

Question asked by redflow on May 14, 2018
Latest reply on Jun 1, 2018 by jpotts

Hi all

I'm trying to define a script for a folder rule to update tags of folder content.

I have a script to set tags of all the document of a folder.

I'm trying to create one to update them when I change something in the folder's tags.

function update(pratica, node)
{
     for each (n in node.children)
     {
          if(n.isDocument)
          {
               var newCurrentTagArray = pratica.getTags();
               for each (tNodo in n.getTags())
               {
                    if (!newCurrentTagArray.includes(tNodo))
                         newCurrentTagArray.push(tNodo);
               }
               n.clearTags();
               n.addTags(newCurrentTagArray);
          }
          if(n.isContainer)
          {
               update(pratica, n);
          }
     }
}

var pratica = document;
//aggiorna i tag di tutti i documenti della pratica
update(pratica, pratica);

The problem is to check if in the tags of the document there is some tag that I want to maintain.....how could I user includes and push?

 

Here is the error I get:

ERROR [org.springframework.extensions.webscripts.AbstractRuntime] [http-apr-8080-exec-729] Exception from executeScript: 0414956638 Failed to execute script 'workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b': 0414956637 Java class "[Ljava.lang.String;" has no public instance field or method named "includes". (workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b#10) org.alfresco.scripts.ScriptException: 0414956638 Failed to execute script 'workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b': 0414956637 Java class "[Ljava.lang.String;" has no public instance field or method named "includes". (workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b#10) at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:261) at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:244) at org.2018-05-14 14:37:19,494 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] [http-apr-8080-exec-729] Exception from executeScript: 0414956638 Failed to execute script 'workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b': 0414956637 Java class "[Ljava.lang.String;" has no public instance field or method named "includes". (workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b#10) org.alfresco.scripts.ScriptException: 0414956638 Failed to execute script 'workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b': 0414956637 Java class "[Ljava.lang.String;" has no public instance field or method named "includes". (workspace://SpacesStore/f9cf4383-279b-4704-9374-8070b990400b#10) at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:261) at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:244) at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:150) at sun.reflect.GeneratedMethodAccessor1854.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpointalfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:150) at sun.reflect.GeneratedMethodAccessor1854.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint

 

Thank you!

Outcomes