Record Producer - Check if User Registered Already

michaelcory
Giga Expert

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.

1 ACCEPTED SOLUTION

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.

View solution in original post

23 REPLIES 23

You were missing a comma. Also can you send me a record screenshot in u_attendee table.



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');


var att = new GlideRecord('u_attendee');



gs.log('++++++++++tc   ++++++++++++++'+tc );


gs.log('++++++++++att ++++++++++++++'+att );



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;


}


}


}, // you missed a comma here



type: 'RegisterAttendee'


});



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

Thank you!   Below are screen shots of the Record Producer form and screenshot of u_attendee record



find_real_file.png



find_real_file.png


Try this



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');


var att = new GlideRecord('u_attendee');



gs.log('++++++++++tc   ++++++++++++++'+tc );


gs.log('++++++++++att ++++++++++++++'+att );



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;


}


}


}, // you missed a comma here



type: 'RegisterAttendee'


});



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

Still getting null answer in alert and Attendee Already Registered alert and the form submits and generates the Attendee record. Log entries below



find_real_file.png


I made few more corrections. try now




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;


}


}


}, // you missed a comma here



type: 'RegisterAttendee'


});



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