cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a folder.

anand6105
Champ in-the-making
Champ in-the-making
HI,
I want to create a folder within a folder using activiti workflow. I use the following code to create a folder :

var node=companyhome.childByNamePath("Sites/dmp/documentLibrary");
         if(node != null) {
            node.createFolder(bc_brandName);
         }
This code is working. Now what if I want to create a folder within  "Sites/dmp/documentLibrary/Tide", Tide being bc_brandName. I tried it with the similar code like:

var node=companyhome.childByNamePath("Sites/dmp/documentLibrary/bc_brandName");
         if(node != null) {
            node.createFolder(bc_productName);
         }
But this is not working. Can anyone help me on this.


Thanks
Anand.
2 REPLIES 2

pmverma
Champ in-the-making
Champ in-the-making
Hi anand6105,
Do you not get any error or log for why this is not working.

it is really helpful to provide error or log here.

P. M. Verma

anand6105
Champ in-the-making
Champ in-the-making
Yes, I was getting an Activiti Engine Exception:"bc_productName" is not defined.
But this is not the issue, because I have defined this in the workflow, model file  as well as share workflow config file. The parent folder is getting created by the same process.

This is the .bpmn file which I am using:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/bpmn20">
  <process id="BrandCreation15" name="Brand Creation 15">
    <startEvent id="startevent1" name="Start" activiti:formKey="bc:initiateBrandCreation"></startEvent>
    <userTask id="usertask1" name="Create Brand" activiti:assignee="${initiator.properties.userName}" activiti:formKey="bc:createBrand">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;           
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>
execution.setVariable('bc_brandID', bc_brandID);
execution.setVariable('bc_brandName', bc_brandName);
execution.setVariable('bc_dobc', bc_dobc);
execution.setVariable('bpm_assignee', task.getVariable('bpm_assignee'));
execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
var node=companyhome.childByNamePath("Sites/dmp/documentLibrary");
         if(node != null) {
            node.createNode(bc_brandName,"cm:folder");
         }
node.save();

</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="usertask2" name="Create Product" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="bc:createProduct">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('bc_productID', task.getVariable('bc_productID'));
execution.setVariable('bc_productName', task.getVariable('bc_productName'));
execution.setVariable('bc_dopc', task.getVariable('bc_dopc'));
var bnode=companyhome.childByNamePath("Sites/dmp/documentLibrary");
         if(bnode != null) {
            bnode.createFolder(bc_productName,"cm:folder");
         }

</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="usertask3" name="Start Campaign"    
   activiti:candidateGroups="GROUP_marketer"
   activiti:formKey="bc:startCampaign">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
execution.setVariable('bc_campaignName', task.getVariable('bc_campaignName'));
</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
<endEvent id="endevent1" name="End"></endEvent>
   <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
   <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="usertask2" targetRef="usertask3"></sequenceFlow>
    <sequenceFlow id="flow4" name="" sourceRef="usertask3" targetRef="endevent1"></sequenceFlow>
  </process>


the model file:
<?xml version="1.0" encoding="UTF-8"?>

<model name="bc:brandModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

    <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
    </imports>

    <namespaces>
        <namespace uri="http://www.infosys.com/bc/model/process/1.0"
            prefix="bc" />
    </namespaces>

    <types>
        <type name="bc:initiateBrandCreation">
            <parent>bpm:startTask</parent>                            
            <mandatory-aspects>
                <aspect>bc:brandProps</aspect>
            </mandatory-aspects>
        </type>               
        <type name="bc:createBrand">
            <parent>bpm:workflowTask</parent>
            <mandatory-aspects>
         <aspect>bpm:assignee</aspect>
                <aspect>bc:brandProps</aspect>
            </mandatory-aspects>           
        </type>
     <type name="bc:createProduct">
            <parent>bpm:workflowTask</parent>
         <overrides>
         <property name="bpm:packageActionGroup">
         <default>add_package_item_actions</default>
         </property>
         <property name="bpm:packageItemActionGroup">
         <default>edit_package_item_actions</default>
         </property>
      </overrides>           
            <mandatory-aspects>
                <aspect>bc:productProps</aspect>
            </mandatory-aspects>           
        </type>
    <type name="bc:startCampaign">
            <parent>bpm:workflowTask</parent>
            <mandatory-aspects>
                <aspect>bc:campaignProps</aspect>
            </mandatory-aspects>           
        </type>

   </types>
              
   <aspects>
      <aspect name="bc:brandProps">
         <properties>
            <property name="bc:brandID">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="bc:brandName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="bc:dobc">
               <type>d:date</type>
               <mandatory>true</mandatory>
            </property>      
         </properties>                
      </aspect>
      <aspect name="bc:productProps">
         <properties>
            <property name="bc:productID">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="bc:productName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="bc:dopc">
               <type>d:date</type>
               <mandatory>true</mandatory>
            </property>      
         </properties>                
      </aspect>
      <aspect name="bc:campaignProps">
         <properties>
            <property name="bc:campaignName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="bc:startDate">
               <type>d:date</type>
               <mandatory>true</mandatory>
            </property>
            <property name="bc:endDate">
               <type>d:date</type>
               <mandatory>true</mandatory>
            </property>      
         </properties>                
      </aspect>

   </aspects>   
</model>


and share config file for the particular properties:
<config evaluator="string-compare" condition="activiti$BrandCreation15">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="bpm:comment" />
               <show id="bc:brandID"/>
               <show id="bc:brandName"/>
               <show id="bc:dobc" />
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="info" appearance=""
                  template="/org/alfresco/components/form/2-column-set.ftl" />
               
               <set id="work" appearance="title" label-id="workflow.set.work" />
               <set id="other" appearance="title" label-id="workflow.set.other" />
               <set id="response" appearance="title" label-id="workflow.set.response" />

               <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 95%</control-param>
                  </control>
               </field>

               <field id="bpm:workflowDueDate" label-id="workflow.field.due"
                  set="info" />
               <field id="bpm:workflowPriority" label-id="workflow.field.priority"
                  set="info">
                  <control
                     template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="bc:brandID" label="Brand ID"/>
               <field id="bc:brandName" label="Brand Name"/>
               <field id="bc:dobc" label="Date of Brand Creation"/>

               <field id="bpm:comment" label-id="workflow.field.comment"
                  set="response">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

<config evaluator="task-type" condition="bc:createBrand">
      <forms>
         <form>
            <field-visibility>
               <show id="message" />
               <show id="bpm:assignee" />
               <show id="bpm:comment" />
               <show id="transitions" />
               <show id="bc:brandID"/>
               <show id="bc:brandName"/>
               <show id="bc:dobc"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="info" appearance=""
                  template="/org/alfresco/components/form/2-column-set.ftl" />
               <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
               
               <set id="work" appearance="title" label-id="workflow.set.work" />
               <set id="other" appearance="title" label-id="workflow.set.other" />
               <set id="response" appearance="title" label-id="workflow.set.response" />


               <field id="message" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               
               <field id="bc:brandID" label="Brand ID"/>
               <field id="bc:brandName" label="Brand Name"/>
               
               <field id="bc:dobc" label="Date of Brand Creation"/>
               <field id="bpm:assignee" label-id="workflow.field.assign_to"
                  set="assignee" />
               <field id="bpm:comment" label-id="workflow.field.comment"
                  set="response">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               <field id="transitions" set="response" />

            </appearance>

         </form>
      </forms>
   </config>   


<config evaluator="task-type" condition="bc:createProduct">
      <forms>
         <form>
            <field-visibility>
               <show id="message" />
               <show id="bpm:assignee" />
               <show id="bpm:comment" />
               <show id="packageItems" />
               <show id="transitions" />
               <show id="bc:productID"/>
               <show id="bc:productName"/>
               <show id="bc:dopc"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="info" appearance=""
                  template="/org/alfresco/components/form/2-column-set.ftl" />
               <set id="items" appearance="title" label-id="workflow.set.items" />
               <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
               
               <set id="work" appearance="title" label-id="workflow.set.work" />
               <set id="other" appearance="title" label-id="workflow.set.other" />
               <set id="response" appearance="title" label-id="workflow.set.response" />


               <field id="message" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               
               <field id="bc:productID" label="Product ID"/>
               <field id="bc:productName" label="Product Name"/>
               
               <field id="bc:dopc" label="Date of Product Creation"/>
               <field id="packageItems" set="items" />

               <field id="bpm:assignee" label-id="workflow.field.assign_to"
                  set="assignee" />
               <field id="bpm:comment" label-id="workflow.field.comment"
                  set="response">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               <field id="transitions" set="response" />

            </appearance>

         </form>
      </forms>
   </config>


<config evaluator="task-type" condition="bc:startCampaign">
      <forms>
         <form>
            <field-visibility>
               <show id="message" />
               <show id="bpm:assignee" />
               <show id="bpm:comment" />
               <show id="transitions" />
               <show id="bc:campaignName"/>
               <show id="bc:startDate"/>
               <show id="bc:endDate"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="info" appearance=""
                  template="/org/alfresco/components/form/2-column-set.ftl" />
               <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
               
               <set id="work" appearance="title" label-id="workflow.set.work" />
               <set id="other" appearance="title" label-id="workflow.set.other" />
               <set id="response" appearance="title" label-id="workflow.set.response" />


               <field id="message" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               
               <field id="bc:campaignName" label="Campaign Name"/>
               <field id="bc:startDate" label="Start Date"/>
               
               <field id="bc:endDate" label="End Date"/>
               <field id="bpm:assignee" label-id="workflow.field.assign_to"
                  set="assignee" />
               <field id="bpm:comment" label-id="workflow.field.comment"
                  set="response">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               <field id="transitions" set="response" />

            </appearance>

         </form>
      </forms>
   </config>


Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.