Error:Server function execution dropped.(Returned absolute null). Check your Script Include settings

pallav_nagar
Tera Contributor

Hi @Ankur Bawiskar & Team,

Use Case : Check Seat Availability 

Scenario 

Before enrolling in an employee, verify that the selected training course has available seats.


When selecting the Training Course on a new Employee Enrollment record, I get this error:
System Error: Server function execution dropped. (Returned absolute null). Check your Script Include settings.

1. GlideAjax enabled Script Include code:

var CheckCourseSeatAvailability = Class.create();
CheckCourseSeatAvailability.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    checkSeatsAvailable: function() {
        // 1. Get the course ID sent from the client side
        var courseId = this.getParameter(sysparm_course_id);
       
        if (!courseId)
            return "ERROR: Client script failed to pass sysparm_course_id.";

        // 2. Query the Training Courses table
        var courseGR = new GlideRecordSecure('x_1947705_traini_0_training_courses');
        if(courseGR.get(courseId)) {
            var seats = courseGR.getValue('available_seats');
        // 3. Check if field is completely blank/null in DB
            if (seats === null || seats === undefined || seats === '') {
                return "ERROR: The field available_seats is blank on this record.";
            }
            return String(seats);
        }
        return "ERROR: Record not found in training_courses for ID: " + courseId;
    },
    type: 'CheckCourseSeatAvailability'
});

 

2. Client Script code: 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   //Type appropriate comment here, and begin script below

   // 1. Initialize GlideAjax calling Script Include
   var ga = new GlideAjax('x_1947705_traini_0.CheckCourseSeatAvailability');
   ga.addParam('sysparm_name', 'checkSeatsAvailable');
   ga.addParam('sysparm_course_id', newValue); // Passes the selected course sys_id
   
   // 2. Execute server call asynchronously
    ga.getXMLAnswer(function(response) {
        // 3. Handle physical network dropping or absolute server crashes
        if (response === null || response === undefined || response === '') {
            g_form.addErrorMessage('System Error: Server function execution dropped. (Returned absolute null). Check your Script Include settings.');
            return;
        }

        // 4. Handle structural error strings returned from our server-side script logic
        if (response.indexOf('ERROR') > -1) {
            g_form.addErrorMessage('System Validation Error: ' + response);
            return;
        }
       
        // 5. Process validation logic
        var availableSeats = parseInt(response, 10);

        if (isNaN(availableSeats)) {
            g_form.addErrorMessage('System Error: Server responded with unparseable data data: "' + response + '"');
        } else if (availableSeats <= 0) {
            g_form.clearValue('course');
            g_form.addErrorMessage('This course is full. Please select another training course.');
        } else {
            g_form.showFieldMsg('course', 'Seats available: ' + availableSeats, 'info');
        }
    });
}


Could anyone please assist and resolve errors to make this Script Include working?

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@pallav_nagar 

things to check

1) is script include client callable

2) both script include and client scripts are in same scope

3) if different scope then is script include accessible from all scopes and you are calling it with complete API name from GlideAjax

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi ,

Please find my responses below:

1) is script include client callable - Yes, as mentioned above, it's a GlideAjax enabled/client-callable script include.

2) both script include and client scripts are in same scope - Yes, both are within same scope

3) if different scope then is script include accessible from all scopes and you are calling it with complete API name from GlideAjax - Yes, I am calling it with complete API name from GlideAjax