The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create Run Server Side Script to test Script Include

escanor
Giga Contributor

Hi guys,

I'm trying to create a Run Server Side Script to test one of my script include. But i'm still new with this ATF and don't know how to wirte it. This script below is one of my scipt include. PLs help me to write a run server script to test it ! 

var CalAge = Class.create();
CalAge.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	generateAge: function() {
		var dob = this.getParameter('sysparam_id');
		var today = new GlideDateTime();
		var todayYear = today.getYearLocalTime();
		var bday = new GlideDateTime(dob.toString());
		var bdayYear = bday.getYearLocalTime();
		var age =todayYear - bdayYear;
		return age;
	},
	type: 'CalAge'
});

or this one

var EmailValid = Class.create();
EmailValid.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	isEmailValid: function(email){
			var getEmail = this.getParameter('sysparm_id') || email;	
			var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}/; 
			return regex.test(getEmail);
	},
    type: 'EmailValid'
});
1 ACCEPTED SOLUTION

RAHUL Khanna1
Mega Guru

Hi escanor, 

 

I understand you are trying to test the script Include. The script include what you have written is used to call in client-scripts. How ever you can test the same in the background script, by writing the following code. I did that and could get some result. 

find_real_file.png

 

 

 

View solution in original post

6 REPLIES 6

SanjivMeher
Kilo Patron
Kilo Patron

Do you want to call it from a client script? These scripts seems to be Client callable script include


Please mark this response as correct or helpful if it assisted you with your question.

yeah dude. I created it for validating some fields of my application form. And now i want to write a test script for it 

Varsha21
Mega Guru
Hii escanor,
 
it seems that you are validating the age and email field at client side..something like that..
in this case you need to write client script,
and call Script includes ... by using GlideAjax api.
 
following link will help you to call script include with different ways
 
 
if you wan call one script include from another script include then following thread is useful
 
 
 
still if you face any kind of issue ..reply for same.
if useful mark it correct or helpful.
 
 
Regards,
Varsha.
 
 
 

 

RAHUL Khanna1
Mega Guru

Hi escanor, 

 

I understand you are trying to test the script Include. The script include what you have written is used to call in client-scripts. How ever you can test the same in the background script, by writing the following code. I did that and could get some result. 

find_real_file.png