Validate Login Details

Soma Sekhar M
Tera Contributor

I have a one custom application that will contain a user registration form , login form , varieties of books with their description and price.

When I submit details from login page i need to validate user name and password of the registered users how can i write a code to validate? if its valid i will display the list of books otherwise give an alert like enter a valid username and password.

13 REPLIES 13

@jaheerhattiwale I tried the same with After Business with insert action as below but it's not redirecting to the list view of books details

 

(function executeRule(current, previous /*null when async*/) {
//var a=current.user_name;
//var b=current.password;
var gr = new GlideRecord('x_881103_book_cart_user_details');
gr.addQuery('email_id',current.user_name.toString());
gr.query();
while (gr.next()) {
if (gr.password.getDecryptedValue() == current.password.toString()) {
//gs.addInfoMessage('true');
gs.setRedirect("https://dev51184.service-now.com/now/nav/ui/classic/params/target/x_881103_book_cart_books_list.do%3...");
}
}
})(current, previous);

@Soma Sekhar M Add a log in if block and check if we are getting the log or not

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@jaheerhattiwale as per ur guidelines i added a info log message in the business rule code as below
(function executeRule(current, previous /*null when async*/) {
//var a=current.user_name;
//var b=current.password;
var gr = new GlideRecord('x_881103_book_cart_user_details');
gr.addQuery('email_id',current.user_name.toString());
gr.query();
while (gr.next()) {
if (gr.password.getDecryptedValue() == current.password.toString()) {
//gs.addInfoMessage('true');
gs.info("navigate books list");
//gs.setRedirect("https://dev51184.service-now.com/now/nav/ui/classic/params/target/x_881103_book_cart_books_list.do%3...");
}
}
})(current, previous);


i checked with sys logs but i got message like as below

SomaSekharM_0-1670483230487.png

The selected record the result

@Soma Sekhar M Search for the text "navigate books list" in Message field of log table

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023