cancel
Showing results for 
Search instead for 
Did you mean: 

Execute a custom javascript in workflow-form.js

rubiecasana
Champ in-the-making
Champ in-the-making
I tried to create custom script that I want to call if the workflow status is complete. In the workflow-form.js, I am already able to know the status of the workflow. So I created an if statement that executes the script below. But it's not working. (Note: the script below is working when run in the javascript  console)

var nodeId = document.id;

var url = encodeURIComponent(document.nodeRef);
//nodeId = "ee9e3698-f6f7-438f-8f58-1015e37c7fc9";
var theDocument = search.findNode("workspace://SpacesStore/" + nodeId);
//logger.log(theDocument);

var cats = theDocument.properties["cm:categories"];
var summary = theDocument.properties["cm:summary"];

theDocument.properties["cm:summary"] = "Approved";
//var summary = theDocument.properties["cm:summary"];
theDocument.save();

Anyone's help is very much appreciated.
5 REPLIES 5

rubiecasana
Champ in-the-making
Champ in-the-making
I also added the same code in parallelreview_processdefinition.xml, restarted alfresco but no luck.

vandana_pal
Champ in-the-making
Champ in-the-making
Hi,

Can you share the code snippet of  how you are calling  your custom javascript from workflow-form.js.


Thanks,
Vandana

rubiecasana
Champ in-the-making
Champ in-the-making
i just inserted it after this code.
var status = this.workflow.isActive ? this.msg("label.workflowIsInProgress") : this.msg("label.workflowIsComplete");
            Dom.get(this.id + "-statusSummary").innerHTML = $html(status);
            Dom.get(this.id + "-status").innerHTML = $html(status);
      if(status == "Workflow is Complete")
         {

   ///script goes here
}

vandana_pal
Champ in-the-making
Champ in-the-making
Hi,

In share All javascript files gets minified to *-min.js. there is workflow-form-min.js, are you doing the changes in this file?

Thanks,
Vandana

rubiecasana
Champ in-the-making
Champ in-the-making
Hi Vandana,

Yes. I've done the changes in workflow-min.js.

Hi,

In share All javascript files gets minified to *-min.js. there is workflow-form-min.js, are you doing the changes in this file?

Thanks,
Vandana