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 @Dr Atul G- LNG ,

 

Thank for your reply,

But can you please let me know how we can achieve this in workflow

Hi @suuriya 

 

Workflow will be tough here, as need to write script. Try with flow. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG ,

 

Thanks for your suggestion but I'm adding this requirement in the existing workflow that we have

Sumanth16
Kilo Patron

Hi @suuriya , 

 

Configure If workflow activity and query approver table and get values  of name and field . And in if activity add the conditions like if name is empty (or) approver active is false then return yes (or) no.

 

 

var formsme = current.variables.form_sme.sys_id;//to get the values of the field

 

 

 

If it is return yes then add Create Task activity (or) you can add the Run Script activity, in that activity add script to genearte Tasks with required assignment group.

 

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 the reply

In workflow i have written a script in if activity even tho the approver field is empty in mentioned table is not going for yes condition it is going to no  condition

 

answer = ifScript();

function ifScript() {

    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);
    item_access_approvers.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";
       }else{
            return "no";
       }  
    }//end of while
}//end of ifscript
suuriya_0-1709027023621.png

 

while submitting the request i select the last record which doesn't have approver details but still it is following no path

 Can you please let me know what need to be corrected? in script

suuriya_1-1709027153251.png