Workflow being stopped for Approval if additional certs are not validated

HenryD
Tera Guru

Hello, I have ran into a issue where I need to query in a business rule or workflow where I must stop the Approver from hitting "Approved" on the "task" if the user who submitted the req item does not have the validated certs that have been approved or basically no matter how much they click approve to not proceed the request until they are validated. We keep an additional table for these certificates that are submitted thru the RITM and once they are approved, they have a "Cert validation" field that turns "true" on the table when it has been approved. Also, based on 2 types of access they either have 2 or 3 certificates that need to be validated.

 

I've been back and forth with a business rule and with a script activity within the workflow but have not been successful.

 

Any help is appreciated. 

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

Ideally, from the Approver's standpoint you would want the Cert validation field to update a field or variable on the RITM when true, so then you can have a workflow activity to wait for that before the Approval record is generated.  If that's not feasible then a Business Rule on the approval record before Update with a Filter condition like State changes to Approved should work.  The script should check the Approval for or Approving record to see if it is a RITM, and/or a specific Catalog Item, if that applies, then check the cert validation table, ultimately preventing the update with a message if the conditions are not met.  Post your script attempt using the insert code icon (</>) and we'll get it sorted.

Hello, right now i have the following script in my wf activity script after the "create task" activity runs in the wf, 

 

(function execute(current, workflow) {

    var requestedFor = current.requested_for; //user requesting access

    var testt1 = new GlideRecord('u_certs');
    testt1.addQuery('u_user', requestedFor); //user submitted arts
    testt1.addQuery('u_item', 'Cert 1'); //name of cat item
    testt1.addQuery('u_certificate_validated', 'True') //validated cert
    testt1.query();

    if (testt1.next()) {
        gs.info(' User has Approved Cert');
        return true;
    } else {
        gs.addErrorMessage('Approval cannot proceed due to unvalidated Cert.');
        return false; //stop the wf
    }

})(current, workflow);
 
 
This is shooting out the error message, but I have yet to get it to work with a working "Type of Access" that would check for based on "Classified" access, I need Cert 1 & 2 to be validated. Another type of access I need is for an Unclassified Access, I need Cert 1, Cert 2 & Cert 3 to be validated. & a way for the approver to be able to click the approve button & not let it go thru.