cancel
Showing results for 
Search instead for 
Did you mean: 

addAspect does not work?

shea
Champ in-the-making
Champ in-the-making
Can someone please help?
I am not able to addAspect to a space using the following JavaScript:

var aspectName = "dynamicSmiley FrustratedomeMetadata";
var result = false;
….
var someFolder = rootFolder.createFolder("someFolder");  <– This folder was created.
result = someFolder .addAspect(aspectName);
if (result) {
      someFolder .createFolder("success");  <– This folder was created.
} else {
      someFolder .createFolder("failed");
}

Did I miss anything?
Thanks
10 REPLIES 10

shea
Champ in-the-making
Champ in-the-making
The example that I posted before actually works.

Does anyone know how to add built-in "effectivity" aspect to a folder?

The code below does not work:
someFolder.addAspect("app:effectivity");

Thanks

mikeh
Star Contributor
Star Contributor
It's "cm:effectivity"

Thanks,
Mike

shea
Champ in-the-making
Champ in-the-making
Thank you. It works.  Appreciated your help.

shea
Champ in-the-making
Champ in-the-making
After I added a custom aspect to a node (say "A") using JavaScript successfuly, I tried to uploada file under the "A" folder.
The file was uploaded, but I was not asked to enter the custom aspect properties.

Does anyone know what I did wrong?  I thought the custom aspect is inherited from the node.

Thanks

mikeh
Star Contributor
Star Contributor
No, aspects are not inherited. You can cause them to be by creating an "inbound" rule to apply the aspect.

Thanks,
Mike

shea
Champ in-the-making
Champ in-the-making
Can I create an inbound rule using JavaScript?  Is there an example that you can provide?

Thanks

mikeh
Star Contributor
Star Contributor
Copy your script into Data Dictionary/Scripts then for the rule's action, choose "Execute a script"

Thanks,
Mike

shea
Champ in-the-making
Champ in-the-making
Hi MIke,

I don't know how to create rule using JavaScript after adding aspect to it.
Is there  an example?

My code below:
somefolder.addAspect("cm:effectivity");  <– built-in aspect created for someFolder
somefolder.addAspect("dynamic:someCustomeAspect");  <- custome aspect created for someFolder
// need code to add rule here ??

Thanks

rrobles
Champ in-the-making
Champ in-the-making
I think this post it's relate with http://forums.alfresco.com/en/viewtopic.php?f=36&t=24404
In the other post I commented that I have the similar problem. I have the next script


  nodes = search.luceneSearch("TYPE:\"ct:customFolder\"");
  for each (var node in nodes)
  {
    if (!(node.hasAspect("ct:newAspect")))
    {
      node.addAspect("ct:newAspect");
       node.save(); 
    }
   
  }
And When I executed, I get next error


Unable to create the action because of an error: 00270410 Failed to execute script 'workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0': 00270409 TypeError: Cannot find function AddAspect. (workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0#14)
org.alfresco.scripts.ScriptException: 00270410 Failed to execute script 'workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0': 00270409 TypeError: Cannot find function AddAspect. (workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0#14)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:239)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:187)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:309)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:234)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:158)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy185.executeScript(Unknown Source)
        at org.alfresco.repo.action.executer.ScriptActionExecuter.executeImpl(ScriptActionExecuter.java:170)
        at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
        at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:711)
        at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:648)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:510)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:498)
        at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:719)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:309)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:234)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:158)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy25.executeAction(Unknown Source)
        at org.alfresco.web.bean.actions.RunActionWizard.finishImpl(RunActionWizard.java:101)
        at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:124)
        at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:121)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:327)
        at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:130)
        at org.alfresco.web.bean.wizard.WizardManager.finish(WizardManager.java:599)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
        at javax.faces.component.UICommand.broadcast(UICommand.java:109)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
        at sun.reflect.GeneratedMethodAccessor390.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy169.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
        at sun.reflect.GeneratedMethodAccessor390.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy169.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.alfresco.error.AlfrescoRuntimeException: 00270409 TypeError: Cannot find function AddAspect. (workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0#14)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:483)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:235)
        … 99 more
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function AddAspect. (workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0#14)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
        at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356)
        at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3368)
        at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3428)
        at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2052)
        at org.mozilla.javascript.gen.c11._c0(workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0:14)
        at org.mozilla.javascript.gen.c11.call(workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.gen.c11.call(workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0)
        at org.mozilla.javascript.gen.c11.exec(workspace://SpacesStore/b6f4afce-f541-40d2-ad9f-3cb53f784eb0)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:467)
        … 100 more

Anyone know other way to to it?
Thanks