cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a confirmation dialog before approving a review step of a workflow in alfresco share

someone1050
Champ on-the-rise
Champ on-the-rise
I want to add a confirmation dialog before an approving review step in Alfresco's workflow, as shown in the picture for more precision

http://i.imgur.com/F3XWLSc.png

I've try to do it in a custom activiti-transitions.ftl,

C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\form\controls\workflow\custom-activiti-transitions.ftl

but it doesn't work correctly. I tried to do that with 2 javascript alert like here :



    <#if form.mode == "edit"
    && ((form.data['prop_bpm_status']??
    && form.data['prop_bpm_status'] != 'Completed')
    || form.data['prop_bpm_status']?? == false)>

    <script type="text/javascript">//<![CDATA[
    (function()
    {
       new Alfresco.ActivitiTransitions("${fieldHtmlId}").setOptions(
       {
          currentValue: "${field.control.params.options?js_string}",
          hiddenFieldName: "${field.name}"
       }).setMessages(
          ${messages}
       );
    })();
    alert("test !!!!!");
    //]]></script>

    <div class="form-field suggested-actions" id="${fieldHtmlId}">
       <div id="${fieldHtmlId}-buttons">
    <script type="text/javascript">//<![CDATA[
    alert("div button ?  !!!!!");
    //]]></script>
       </div>
    </div>
    </#if>


these 2 alerts appear before the buttons(look at the picture) "Approuver" and "Rejeter" are generated in the page .

You have the images of these two alerts in this link :

http://imgur.com/3vnP7sB,kf4Hud6#0
2 REPLIES 2

hardik1512
Star Contributor
Star Contributor
You can do this by overriding activiti-transitions.js file which is @ path share\components\form\workflow.  This file contains a function ActivitiTransitions_onClick  which is called when any button in clicked. You can add your condition and custom code there.

someone1050
Champ on-the-rise
Champ on-the-rise
thank you, but how can i do a confirm dialog with alfresco , i tried this

<javascript>
      onClick:function c(n,o){
        secure = true;
        if(o.get("value") == "Approuver"){

              var dialog = Alfresco.util.PopupManager.displayPrompt(
   {
      title: "Attention !",
      text: "êtes-vous sûr d'approuver ce formulaire ?",
      buttons: [{text: "OK",handler: function error_onOk()
      {this.destroy();},isDefault: true},{text: "Annuler",handler: function Ann()
      {this.destroy();secure = false; },isDefault: true}]}, this);
         /*var conf = confirm("êtes-vous sûr d'approuver ce formulaire ?");
          if (conf == false) {
            secure = false;}*/
          }
        if (secure){
         o.set("disabled",true);var m=o.get("id");var l=m.substring(this.id.length+1);
         var k=this._getHiddenField();
         f.setAttribute(k,"value",l);
         if(Alfresco.logger.isDebugEnabled()){Alfresco.logger.debug("Set transitions hidden field to: "+l)}
            this._generateTransitionsHiddenField();
         Alfresco.util.submitForm(o.getForm())}}
</javascript>


the dialog appear but, when i click on "Annuler", the var "secure" is not modified in the handler's fonction
someone has another solution ?

thank you