I am able to run the code:-
=========================================================
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' && 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);
}
================================================================================================
This code is restricting me to change to Resolved status, even if there are no workflows or all the workflows attached are Approved or Completed status. On checking logs, I am getting below error. There are only 5 workflows attached to the cr ticket. Please guide how to resolve this issue.
Error Log----------------------------------------------------------
03/02 16:46:08.14 UATVWSDM01 spelsrvr 8156 SIGNIFICANT zresolve_date.spl 3 status: RE, resolve_date: 03/02/2021 16:46:08
03/02 16:46:11.05 UATVWSDM01 sqlagt:select5 6088 SIGNIFICANT prov_base.c 1010 SQL Query has returned (5000) rows for (domsrvr/superuser/ServiceDesk). Clause (SELECT crwf.id FROM crwf) Input (<None>)
03/02 16:46:11.50 UATVWSDM01 sqlagt:select5 6088 SIGNIFICANT prov_base.c 1025 SQL Query has finished (9217) rows for (domsrvr/superuser/ServiceDesk). Clause (SELECT crwf.id FROM crwf) Input (<None>)
03/02 16:46:11.52 UATVWSDM01 web:local 5628 ERROR freeaccess.spl 25902 update checkin of cr:679824 failed: Please complete all pending workflow before changing the status to Resolved.
Original Message:
Sent: 10-12-2018 12:06 PM
From: Grant Bruneau
Subject: Re: Prevent request status change if all workflow tasks are not completed
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);
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(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.