Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Make fields mandatory using UI action

Carman
Giga Contributor
current.state = -5;
current.type = "emergency";
g_form.setMandatory('category', true);
g_form.setMandatory('cmdb_ci', true);
g_form.setMandatory('priority', true);
g_form.setMandatory('risk', true);
g_form.setMandatory('impact', true);
g_form.setMandatory('short_description', true);
var arr = g_form.getMissingFields();
alert("The ID s of fields that are mandatory are not filled : " + arr);
current.update();

Couldn't get my code to work. I'm trying to set form fields as mandatory in Emergency changes when the state is new. 

What is missing from my code?

1 ACCEPTED SOLUTION

Musab Rasheed
Kilo Patron

Hello,

Please follow below link, Mark my answer as correct if that helps.

https://community.servicenow.com/community?id=community_question&sys_id=a323c3581b3dc110faf255fa234bcb78

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

View solution in original post

3 REPLIES 3

Mahesh23
Mega Sage

Hi,

You want some of the fields should be mandatory when state is new ?

If yes create new UI policy where condition is State is New and Type is Emergency after create UI action for the fields which you want to be be mandatory.

find_real_file.png

find_real_file.png

Musab Rasheed
Kilo Patron

Hello,

Please follow below link, Mark my answer as correct if that helps.

https://community.servicenow.com/community?id=community_question&sys_id=a323c3581b3dc110faf255fa234bcb78

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Thanks!