Identify all mandatory fields in Business Rule

Sruthi17
Kilo Sage

The Scenario is

When we move the change ticket from new to peer review, need to check if mandatory fields in the change tasks are filled

If the mandatory fields of the change tasks are not filled we need throw a error message

Is there any prebuilt function in servicenow server script to identify all the mandatory fields on a form

3 REPLIES 3

ABHAY_M
Tera Guru

i think you have to handle those feild value is emty or not bby script in BR

like 
if(current.short_descrtion ==''''}
{

gs. add error mesasge

current.setabort action

}

Thank you

Even I used the same in my script. So I wanted to know is there any other prebuilt function which does the same

Sukhbir Singh2
Giga Guru

Hi

You can use the nil() method of GlideElement API.

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server_legacy/c_GlideElementAPI#r_GlideElement-nil?navFilter=glideelement

If(current.assigned_to.nil()){

// Do Something

}

 

find_real_file.png

 

But the approach below will also work fine.

if(!current.assigned_to || current.assigned_to == ""){

// Do something

}

 

Please mark my answer as correct/helpful, if it helped

Thanks