I have a requirement to create a validation to prevent users from creating incidents with a service

kellenp
Tera Contributor
I have a requirement to create a validation to prevent users from creating incidents with a service
 
4 REPLIES 4

Shivalika
Mega Sage

Hello @kellenp 

 

I wrote below "On Change client script and its working for both new records and if there is any existing record where they want to change it, its working there as well". 

 

Shivalika_0-1742629518336.png

 

Shivalika_1-1742629648028.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   if(g_form.isNewRecord() && g_form.getValue('business_service')== '26e46e5b0a0a0bb4005d1146846c429c')
   {
	g_form.addErrorMessage("You cannot use this Service");
	return false;
   }

   if(newValue == '26e46e5b0a0a0bb4005d1146846c429c')
   {
	g_form.addErrorMessage("You cannot use this Service");
	g_form.clearValue('business_service');
	return false;
   }

   //Type appropriate comment here, and begin script below
   
}

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@kellenp 

what do you mean by prevent users from creating incidents with service?

is it some variable on record producer etc?

what's the exact business requirement? share screenshots.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Shivalika
Mega Sage

Hello @kellenp 

 

Please confirm if you checked my answer. Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for my efforts and also it can move from unsolved bucket to solved bucket. 

 

Regards, 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeE

Shivalika
Mega Sage

Hello @kellenp 

 

Please confirm if you checked my answer. Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for my efforts and also it can move from unsolved bucket to solved bucket. 

 

Regards, 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeE