cancel
Showing results for 
Search instead for 
Did you mean: 

How to rename space and content from within a workflow?

jarrett
Champ in-the-making
Champ in-the-making
Hello,

I am new advanced workflows and I cannot figure out how to rename a piece of content or a the parent space of a piece of content from within a workflow.

I've tried this inside of my workflow


<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
    <script>
        <expression>
            var Id = document.properties["ygrd:DocumentId"];
            space.name = Id + " - " + space.name;
            space.save();
        </expression>
    </script>
</action>

and get this error:


06:29:07,288 ERROR [graph.def.GraphElement] action threw exception: Failed to execute supplied script: Failed to execute supplied script: ReferenceError: "document" is not defined. (AlfrescoScript#1)
org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: Failed to execute supplied script: ReferenceError: "document" is not defined. (AlfrescoScript#1)

Any help or insight would be appreciated. Thank you.
2 REPLIES 2

jarrett
Champ in-the-making
Champ in-the-making
Hello,

Turns out this works for changing the name of a document


bpm_package.children[0].properties["ygrd:DocumentTitle"] =  "Blah";
bpm_package.children[0].save();

will change the title of the document. changing the title of the space is still a bit of a mystery, also change the name (not the title) of a document seems to be a hassle too. I am looking for the simplest way to keep the name of the document with the correct file extention.

mabayona
Champ on-the-rise
Champ on-the-rise
To rename the space name is not a mistery. It is just something like:

space.properties["cn:name"] = "the-new-name";
space.save();

all you need is to get hold of the space. If the space is the space containing the document, probably is something like;

bpm_package.properties["cn:name"] =  "the-new-name";
bpm_package.save();

to change the name of the document is similar:

bpm_package.children[0].properties["cn:name"] =  "Blah";
bpm_package.children[0].save();