cancel
Showing results for 
Search instead for 
Did you mean: 

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

billydekid
Star Contributor
Star Contributor

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]

1 ACCEPTED ANSWER

UPDATE:

The above solution was not the best solutions since we should reinstall the alfresco.

After some research on Tomcat cache and found no solutions on cache, I then move to Module console.

By execute "show definitions all" I found that my workflow is listed two versions (version 1 and version 2), FYI. I updated from version 1.0 to 1.1 and from this console we saw that Alfresco save two workflows inside.

My problem was that workflow is always use workflow version 1.0 (which known in console is version 1) not 1.1 (know as version 2).

Then I undeploy workflow version 1 by command undeploy definition <workflow id> and my workflow run as expected using the latest version 1.1.

Hope this information helps.

I still wonder, even MMT reported that my workflow updated successfully form 1.0 to 1.1, why alfresco still keep the 1.0 version not overwrite it.

Maybe someone can answer this.

Thanks,

View answer in original post

2 REPLIES 2

billydekid
Star Contributor
Star Contributor

Problem solved.

It seems the problem on how the alfresco load the activiti bpmn files loaded into alfresco apps (I don't know what exactly the correct terms).

Since I checked after deployed the latest AMP (with previous deleted tomcat work and temp dirs & delete alfresco dir inside webapps), this step didn't affect to workflow. Even the bpmn file is the latest deployed into the module dir, the workflow still refer to the old one.

Until I reinstall the fresh new alfresco, install the module (amp) and run the workflow then it works.

I use ALF 5.1.f on Ubuntu 14.04.5.

Thanks,

[bayu]

UPDATE:

The above solution was not the best solutions since we should reinstall the alfresco.

After some research on Tomcat cache and found no solutions on cache, I then move to Module console.

By execute "show definitions all" I found that my workflow is listed two versions (version 1 and version 2), FYI. I updated from version 1.0 to 1.1 and from this console we saw that Alfresco save two workflows inside.

My problem was that workflow is always use workflow version 1.0 (which known in console is version 1) not 1.1 (know as version 2).

Then I undeploy workflow version 1 by command undeploy definition <workflow id> and my workflow run as expected using the latest version 1.1.

Hope this information helps.

I still wonder, even MMT reported that my workflow updated successfully form 1.0 to 1.1, why alfresco still keep the 1.0 version not overwrite it.

Maybe someone can answer this.

Thanks,