- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 01:51 PM
Hi,
I have a Training Class Registration application with Attendee,Training Class, & Training Room tables. A Record Producer form (on Attendee table) allows someone to register for a Class by entering the Attendee Name and selecting a Training Class. The Attendee Name variable references the User table. The Training Class variable references the Training Class table. Training Class variable is mapped to the Training Class table and already includes a reference qualifier (java script call to script includes) that sets the filter to only show Classes with a Status of "Open".
I have a new requirement to check if an Attendee has already registered for a Class that they are trying to select again. Before the Record Producer is submitted, I would need to check the Training Class (sys id) selected against the Attendee Name (User sys id) selected and I assume query the Class related list of Attendees to check if the Attendee sys id is listed. If a match is found, show alert that "Attendee has already registered".
Can this be done in a Business Rule with glide query or is there another way to accomplish it? Any insight into how to do this would be greatly appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2017 11:07 AM
One more correction and you are all set.
var RegisterAttendee = Class.create();
RegisterAttendee.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getAttendee: function() {
gs.log('++++++++++Inside the script include++++++++++++++');
var an = this.getParameter('sysparm_attendee_name');
var tc = this.getParameter('sysparm_class_name'); // Correction
var att = new GlideRecord('u_attendee');
gs.log('++++++++++tc ++++++++++++++'+tc );
gs.log('++++++++++an ++++++++++++++'+an);
att.addQuery('u_attendee_name',an+'');
att.addQuery('u_training_class',tc+'');
att.query();
if(att.next()){
gs.log('++++++++++Inside the if statement+++++++++att.u_attendee_name+++++'+att.u_attendee_name);
if(att.u_attendee_name == an && att.u_training_class == tc){
return true;
}
else {
return false;
}
}
return false; // Added a return false here
}, // you missed a comma here
type: 'RegisterAttendee'
});
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 01:54 PM
Hi Mike,
You will need to write an onSubmit Client script and use glideajax to run a script include to find out if the user has already registered.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 02:05 PM
Hi Sanjiv,
Thanks for the pointer in the right direction. I'll have to do some research on glide ajax to figure out how to code the script includes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 02:07 PM
Follow the below link. You will need to use the example of Synchronous Glide Ajax
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2017 02:05 PM
There are multiple ways do accomplish this.
1. I prefer doing it using onCellEdit client script to add a field message on the User field . As soon as the user changes the value I love to display instance feedback so that user can change the value.
2. As sanjiv mentioned above you can use an onSubmit client script to do all the validation and then stop the record submission. I put this as my second option since stopping I have faced issues earlier by using this.
3. Have an onBefore business rule to check for any validations and the use current.setAbortAction(true)