ScriptAction.execute() produces error

cancel
Showing results for 
Search instead for 
Did you mean: 
qwertz
Active Member II

ScriptAction.execute() produces error

Jump to solution

Hi!

I am trying to perform a transformation.

var action = actions.create("transform");
action.parameters["destination-folder"] = folder;
action.parameters["assoc-type"] = "{http://www.alfresco.org/model/content/1.0}contains";
action.parameters["assoc-name"] = document.name.toString() + "transformed";
action.parameters["mime-type"] = "text/html";
action.parameters["overwrite-copy"] = false;
action.execute(document.getNodeRef());

This produces the following error on line 7:

org.mozilla.javascript.ConsString cannot be cast to org.alfresco.service.namespace.QName

I have read that one should change all JavaScript Strings with the .toString() method in order to resolve the issue and I tried this in the above example, but it still gives me the same error. Have I forgotten anything?

1 Solution

Accepted Solutions
qwertz
Active Member II

Re: ScriptAction.execute() produces error

Jump to solution

ok I just figured it out, line 4 must be changed to

action.parameters["assoc-name"] = (document.name + "transformed").toString(); 

View solution in original post

2 Replies
qwertz
Active Member II

Re: ScriptAction.execute() produces error

Jump to solution

ok I just figured it out, line 4 must be changed to

action.parameters["assoc-name"] = (document.name + "transformed").toString(); 
afaust
Master

Re: ScriptAction.execute() produces error

Jump to solution

In my optinion this would be worth a bug report in the Alfresco JIRA. A constructed string (ConsString) is a valid JavaScript string and should be supported by the Alfresco JavaScript API. Chances are that Alfresco will not fix this though, similar to other long standing issues with the script integration, e.g. the fact that you cannot reliably do === comparisons of strings due to the Java vs. JavaScript type incompatibility (though in other areas Java strings will behave just like JavaScript ones).