The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Simplest way possible to allow self-registration

kjetil
Kilo Contributor

I'm trying to allow people to self-register for Service Now portal in the simplest way possible.

The user should be able to give email address and password (otherwise password will be set randomly) - Optionally they can give FirstName and Last Name as well.

When user click submit they should be registered as a SN user and automatically logged in with a session to ServiceNow as the newly created user.The browser will switch to a new incident as if the user had chosen to create one from scratch.

Anybody up for this?

regards

Kjetil

1 ACCEPTED SOLUTION

TrevorK
Kilo Sage

We are using SAML for our SSO and we do something very similar to this. Our solution has been in place for over 5 years, so there might be much better solutions by now.


We do this for "public" chat because, until I think Istanbul, public (anonymous) chat is not supported.



When the user navigates to the initial Chat screen they are prompted to enter in their name, email, etc. In the background an account is already created for them (because they hit the page) and this account is then updated when they provide the appropriate information and click submit. They are already logged in and ready to use Chat. All the work is done in the SAML login script - we look for when they hit a specific URL and then we do our magic.



In hindsight, with SAML you should also be able to create a public page. Upon submission of the public page you are redirected to ServiceNow and your session auto-logged in with the created user. Perhaps a more elegant solution than ours and the code for doing it probably exists in the Login Script as well.




If you are not using SAML, well, I guess my post is of little help!


View solution in original post

5 REPLIES 5

TrevorK
Kilo Sage

We are using SAML for our SSO and we do something very similar to this. Our solution has been in place for over 5 years, so there might be much better solutions by now.


We do this for "public" chat because, until I think Istanbul, public (anonymous) chat is not supported.



When the user navigates to the initial Chat screen they are prompted to enter in their name, email, etc. In the background an account is already created for them (because they hit the page) and this account is then updated when they provide the appropriate information and click submit. They are already logged in and ready to use Chat. All the work is done in the SAML login script - we look for when they hit a specific URL and then we do our magic.



In hindsight, with SAML you should also be able to create a public page. Upon submission of the public page you are redirected to ServiceNow and your session auto-logged in with the created user. Perhaps a more elegant solution than ours and the code for doing it probably exists in the Login Script as well.




If you are not using SAML, well, I guess my post is of little help!


kjetil
Kilo Contributor

Sounds like something we could go for - excellent tip. We will be using SAML very shortly. Would you mind posting parts/whole script twerk that you did to the login script?


Sorry for the delay in responding - got a bunch of stuff at work that needed to be complete. Here is the code from our login script:


// -=-=-=- START TREVOR'S CHAT MODIFICATION -=-=-=-


  //Capture the URI being accessed    


  var URI = request.getRequestURI();


    gs.log("URI: " + URI);


  // If trying to access the chat page, let my code take over to bypass SSO


  if (URI == '/public_chat/public_chat_login.do' || URI == '/public_chat/public-chat_login.do' || URI == '/public_chat/pub_chat.do' || URI == '/saml_redirector_public_chat.do') {


  var ChatUserCount = 1;


  var qryUser = new GlideRecord("sys_user");


  qryUser.addQuery("user_name","STARTSWITH","chat.user.");


  qryUser.query();




  ChatUserCount = qryUser.getRowCount() + 1;



//gs.log("TK - Row Count: " + qryUser.getRowCount() + "     ChatUserCount: " + ChatUserCount);


  var UserName = 'chat.user.' + ChatUserCount;


  qryUser.initialize();


  qryUser.first_name = 'Chat';


  qryUser.last_name = 'User';


  qryUser.user_name = UserName;


  var UserID = qryUser.insert();


  return UserName;


  }  


// -=-=-=- END TREVOR'S CHAT MODIFICATION -=-=-=-



Any questions at all let me know. It may not be 100% what you want, but shows you how you can intercept requests before they hit authentication so that you can authenticate and pass a user in. This is the code from SAML - the dynamic blocks after take care of updating it to what the user selects.


kjetil
Kilo Contributor

Perfect Trevor, I totally understand you being busy at work - very great full for super feedback. Its nice to see the example script since I'm pretty new to ServiceNow, but think I understand it all now - the way you did it 😉