Charcater Validation

PratikshaAbhang
Tera Contributor

Exclude data patch request  using this condition
Change Type IS Emergency
&&
Sub Type IS ONE OF 400 / 500/600
&& service.justification CONTAINS **Eligible**
Minimum Character limit of 100 characters to be introduced for the below sections of the change ticket

Description

Justification

risk and impact analysis


Minimum Character limit of 15 characters to be introduced for the below sections of the change ticket (the limit is kept 15 as at times these details are attached in excel forms)

Implementation Plan

Backout Plan

2 REPLIES 2

Runjay Patel
Giga Sage

Hi @PratikshaAbhang ,

 

You can write onsubmit client script and use below code.

 

var description = g_form.getValue('description');
	var justification = g_form.getValue('justification');
	var ria = g_form.getValue('risk_impact_analysis');

	if(description.length <= 100 || justification.length <=100 || ria.length <=100){
		alert('Please add at leas 100 character for description,justification and risk impact analysis');
return false;
	}

 

Similarly you can check for "Implementation Plan and Backout Plan" filed for 15 character.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Part 2. In this video i have talked about overview on ServiceNow platform/tool. How you can opt for personal dev instance (PDI)? how to login in ServiceNow instance and navigation to OOB modules. For document please visit: https://servicenowwithrunjay.com/ Follow Facebook page for latest update on

AbdulNow
Tera Guru

Hi @PratikshaAbhang - Just write a BR on Change request table on before Insert or before Update with below as sample.

 

(function executeRule(current, previous /*null when async*/) {
// Check if Change Type is 'Emergency'
if (current.change_type == 'Emergency' &&
(current.sub_type == '400' || current.sub_type == '500' || current.sub_type == '600') &&
current.service.justification.indexOf('Eligible') !== -1) {

// Add logic here to exclude data patch requests
gs.addErrorMessage("This change request is excluded due to data patch conditions.");
current.setAbortAction(true); // Prevents the insertion or update of the record
}
})(current, previous);