Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Update Available Seats After Enrollment

pallav_nagar
Tera Contributor

How to Update Available Seats After Enrollment in Employee Enrollments record using Business Rules in ServiceNow?


Table - Employee Enrollments

Scenario:
Whenever an employee enrolls in a course, automatically decrease the Available Seats count in the related Training Course.

Additional Field(s) Required:
Available Seats (Integer), Total Seats(Integer) on the Training Courses table.

Expected Result:
Each new enrollment automatically reduces the number of available seats.

2 REPLIES 2

Mark Manders
Giga Patron

What did you already try and what didn't work? Especially with a BR, you can just do calculations on the field (enrollment added, look up training course and deduct 1 from the available seats).


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Tanushree Maiti
Tera Patron

Hi @pallav_nagar ,

 

You can try with Async Update BR on your Enrollment table.

 Trigger condition could be when  course changes AND employee is not empty

 

 you can try with this Sample script :

 

var courseGR = new GlideRecord('training_courses'); // Replace with your actual Training Course table name
    if (courseGR.get(current.course)) // Replace 'course' with your exact Reference field name
{         
        if (current.operation() == 'insert') {
            courseGR.available_seats = parseInt(courseGR.available_seats) - 1; //  Decrement Available Seats on Insert
        }
       courseGR.update();
    }

 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti