If condition in workflow for approval

keerthana19
Tera Contributor

I have to create an additional approval if level is division and name is Central data.

In my catalog item I have a variable called ‘Type’ referenced to ‘alm_hardware’ table I have to query the record selected in Type and check if level is division or not(level has 5 choices)

find_real_file.png

If level is not division, then it should check the record selected in parentID for level is division or not this process should repeat until level is division

ParentID is referenced to ‘alm_hardware’ table

 find_real_file.png

If level matches with division check “Name’ field for Central data. (Name field is text field)

Here is the script I was working

 find_real_file.png

You can refer to the word document attached

 

 

7 REPLIES 7

aksh3
Giga Guru

 

Hi keerthana,
 
First of all your script in the if core activity of workflow is having a issue . you need to modify the script. You should not pass the current.variables.vtype within the quotes.
 
I have put the sample script as your pic attached is not clear and are you storing the sys_id in that particular variable which you have used to compare in addQuery().
 
answer = ifScript();
function ifScript()
//Glide the table
{if(current.variables.variableName=="")// pass the varaible name and variable correctly
return "yes";
else
return "no";
}
 
Please mark correct/helpful if it resolves your query or reply to this i will be able to help you more.
 
Regards,
Akshay
 
 
 

MrMuhammad
Giga Sage

Hi,

Your script will be something like below. Please make sure to use the correct names and values for fields and choices in the script below. 

answer = ifScript();
function ifScript()
  var gr =new GlideRecord("alm_hardware");
  gr.addEncodedQuery("sys_id"+current.variables.vType.toString());
  gr.query();
  if(gr.next()){
     if(gr.getValue('u_level') == 'division'){
       return "yes";
     } else{
       var parent = gr.parent.getRefRecord();
       if(parent.getValue("u_level") == 'division'){
         return true;
       } else { return false;}
     } 
      
  }

}

Hope that helps!

Regards,

Muhammad

Regards,
Muhammad

In the line var parent = gr.parent.getRefRecord();

gr.parent, is the parent referring to ParentID field...??

 

yes, please replace it with the correct field name of ParentID. 

Regards,
Muhammad