Cris P
Tera Guru

Hi there,

Here is a Script Include which returns true/false based on your specs (make sure 'Client Callable' is ticked on the same):

var CPcheckDescriptionLength = Class.create();
CPcheckDescriptionLength.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	isLengthSatisified: function(){
		// We can store the value 251 in a system property, or can just set it statically here:
		var minimum = gs.getProperty('STORE_THE_VALUE_IN_PROPERTY') || 251;
		
		// Check if our short desc is less than minimum, return true/false
		return this.getParameter('sysparm_sd') < minimum;
	},

    type: 'CPcheckDescriptionLength'
});

 

Then from your client script call it like this:

function onLoad() {
   //Type appropriate comment here, and begin script below
	
	var ga = new GlideAjax('CPcheckDescriptionLength'); // The name of the Script Include
	ga.addParam('sysparm_name', 'isLengthSatisified'); // The name of the method we want to use in the SI
	ga.addParam('sysparm_sd', g_form.getValue('short_description')); // Pass your short description to the param we define in the SI
	ga.getXMLAnswer(function(response){ // Callback function to use the 'response' from our SI
		jslog(response); // Will be true or false
	});
   
}