Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Task need to be generated if no approver details present in the table

suuriya
Tera Contributor

Hi Community,

 

I have a requirement, there is table (approver table) and in that table 2 fields environment name and approver....in workflow if there is no approver/missing/approver is inactive for any of the record in the table then task need to be generated to x team....how can we achieve this

Can you let me know how to check if approver is present in the table or not 

Thanks in advance

11 REPLIES 11

Hi @suuriya ,

 

Run that script in the background script adding sample records in query and check which lines are printing:

 var isApprover = "";
    var item_access_approvers = new GlideRecord('u_csos_access_approvers');
    item_access_approvers.addQuery('u_csos_environment', current.variables.select_csos_environment.sys_id);//modify query take sysid of cos environment
    item_access_approvers.query();

//additem_access_approvers.getrowcount statement  to print how many records getting from query

    while (item_access_approvers.next()){
       var approvers_list = item_access_approvers.u_csos_approver;
       workflow.debug('approvers_list :- '+approvers_list );
       //gs.print('approvers_list :- '+approvers_list);
       
       if (approvers_list == "" || approvers_list == null){
                 return "yes";//add gs.info to print statement
       }else{
            return "no";//add gs.info to print statement
       }  
    }//end of while
}//end of ifscript
 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

HI  @Sumanth16 

 

Thanks for your reply i tried it, in table for one of the record approver is empty but still it is following no path and not the yes path