CA Service Management

Expand all | Collapse all

Prevent request status change if all workflow tasks are not completed

  • 1.  Prevent request status change if all workflow tasks are not completed

    Posted 10-12-2018 09:27 AM

    Hi everyone,

     

    I have a request to disable users to change the status of a request to Resolved 'RE' (not Closed) if all of request workflow tasks are not in status Complete.

     

    Anyone have maybe a solution how to accomplish this or maybe a macro code that will prevent this?

     

    Many thanks,

     

    Domagoj



  • 2.  Re: Prevent request status change if all workflow tasks are not completed

    Posted 10-12-2018 12:06 PM

    Hi,

     

    I have similar logic I built to stop change orders from transitioning to Implemented if all workflow tasks are not complete. I re-wrote this for request workflow and have not tested it. Please try this in a test env first.

     

    Create a file named z_cr_wf.mod and place in nx_root/site/mods/magic with the following contents.

    MODIFY cr     POST_VALIDATE zCheckPendingWF() 50012 FILTER(status { -> 'RE' } && EVENT("UPDATE"));

     

    Create a file named z_cr_wf.spl and place in nx_root/site/mods/magic with the following contents.

    cr::zCheckPendingWF(...) {
         object wf_list;
         int wf_count;
         string method, wc_workflow;
      method = "cr::zCheckPendingWF";
      logf(MILESTONE, "%s started", method);
     
      //Where clause to check to workflow tasks
      wc_workflow = format("cr = %s AND status = 'PEND')", persistent_id);
       
         uuid who;
         send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
         who=msg[0];
     
      send_wait(0, top_object(), "call_attr", "cr_wf", "sync_fetch", "STATIC", wc_workflow, -1, 0);
      wf_list = msg[0];
      wf_count = msg[1];

      //If there are pending workflow tasks then block the action
      if(wf_count > 0){
              set_error(1);
              set_return_data("Please complete all pending workflow before changing the status to Resolved.");
              return;
      }
      logf(MILESTONE, "%s ended", method);
    }

     

    Test and let me know if it works.



  • 3.  Re: Prevent request status change if all workflow tasks are not completed

    Posted 10-18-2018 04:59 AM

    Thanks Grant,

     

    will test and let you know if it helps.

     

    Best Regards

     

    Domagoj



  • 4.  Re: Prevent request status change if all workflow tasks are not completed

    Posted 10-12-2018 12:17 PM

    Hi,

    gbruneau's solution should work fine but if you want to resolve this using just Data Partition, this one constraint could help:

    NOT( id.[chg]workflow.status.task_complete = 0 ) 

    PS: conditions with "NOT" constraint could work very slow, so use it at your own risk.



  • 5.  Re: Prevent request status change if all workflow tasks are not completed

    Posted 10-12-2018 02:37 PM

    I confess I hardly ever use data partitions.