AnsweredAssumed Answered

Fail to move file on custom activiti workflow (runAs admin)

Question asked by billydekid on Oct 18, 2016
Latest reply on Oct 20, 2016 by billydekid

Hi,

I thought this topic was common asked here but I couldn't found the solution.

 

I created a custom activiti  workflow (AMP module) which will move document when approved.

The part of user task code as shown below:

 

   <userTask id="approved" name="Ack. Document Approved" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:approvedTask">
      <documentation>The document was reviewed and approved.</documentation>
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="runAs">
            <activiti:string><![CDATA[admin]]></activiti:string>
          </activiti:field>
          <activiti:field name="script">
            <activiti:string><![CDATA[var d = new Date(),
  month = '' + (d.getMonth() + 1),
  day = '' + d.getDate(),
  year = d.getFullYear();
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var month = monthNames[d.getMonth()];


if (day.length < 2) day = '0' + day;


// to display
var ddmonyyyy = [day, month, year].join('-');
var hhmmss = d.toLocaleTimeString();


for (var i = 0; i < bpm_package.children.length; i++)
{
  var doc = bpm_package.children[i];


  // Set apporval information aspect
  doc.properties["sam:doc-approval-status"] = 1;
  doc.properties["sam:doc-approval-info"] = "Set via workflow: Approved by " + person.properties.userName + " on " + ddmonyyyy  + " " + hhmmss;
  doc.save();


  // Move document to PUJ root directory
  var dest = companyhome.childByNamePath("Sites/legal-department/documentLibrary/PUJ");
  var res = doc.move(dest);

  logger.log("Doc: " + doc.name + " move to: " + dest + " RES: " + res);
}]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
The file is fail to upload
The log4j log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug

 

File is still fail to move.

Log file also has no information even I put the log and log4j set to debug (log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug).

 

Does anyone know what I might missing to?

 

Thanks,

[bayu]

Outcomes