how to navigate to users form when logged in 1st time

vspk
Giga Expert

Hi

My requirement is:

When user logged in for the 1st time, immediately that user must be navigated to users page ( as attached) so that he/she can fill their particular details. But from the 2nd time they should see their homepage. How to do that ?

find_real_file.png

1 ACCEPTED SOLUTION

Rushit Patel2
Tera Guru

Hi Sneha,



please find below the complete solution. first make script include like below. it is assumed that if user Is new it will not have las login time field filled. it will be empty and for old users it will be always there. make sure no one can edit this field manually.




isnewuser : function () {
 
  var userID     = this.getParameter('sysparm_id');
  var gr = new GlideRecord('sys_user');
  gr.get(userID);
 
  return gr.last_login_time.getDisplayValue();
 
 


},



it looks like this.



find_real_file.png



then make one global UI script.




addLoadEvent(newuserpage);


function newuserpage(){

if(window.GlideAjax && window.jQuery){


  var userID =   window.NOW.user.id;
 
  var glide = new window.GlideAjax('getUser');
    glide.addParam('sysparm_name', 'isnewuser');
  glide.addParam('sysparm_id', userID);
  glide.getXMLWait();
 
  if(glide.getAnswer() == ''){
    $j('#gsft_main').attr('src','https://yourinstance.service-now.com/sys_user.do?sys_id=' +userID );
  }
}
}



it will look like this



find_real_file.png



let me know if u have any questions.



(mark helpful/correct/like if it helps)



Regards,


Rushit Patel


View solution in original post

4 REPLIES 4

Rushit Patel2
Tera Guru

Hi Sneha,



you can make Script Action on event login...   then you can make one custom field on user table ...it will have login counts. if it is 0 then redirect to user form else default home page.



else you can check last login field on user table..if it is blank that means user is logging in first time so redirect them to user form



let me know if u have any questions





regards,


Rushit PAtel


bernyalvarado
Mega Sage

Hi Sneha,



The following may be helpful:



Homepage Splash Page - ServiceNow Wiki



Thanks,


Berny


Rushit Patel2
Tera Guru

Hi Sneha,



please find below the complete solution. first make script include like below. it is assumed that if user Is new it will not have las login time field filled. it will be empty and for old users it will be always there. make sure no one can edit this field manually.




isnewuser : function () {
 
  var userID     = this.getParameter('sysparm_id');
  var gr = new GlideRecord('sys_user');
  gr.get(userID);
 
  return gr.last_login_time.getDisplayValue();
 
 


},



it looks like this.



find_real_file.png



then make one global UI script.




addLoadEvent(newuserpage);


function newuserpage(){

if(window.GlideAjax && window.jQuery){


  var userID =   window.NOW.user.id;
 
  var glide = new window.GlideAjax('getUser');
    glide.addParam('sysparm_name', 'isnewuser');
  glide.addParam('sysparm_id', userID);
  glide.getXMLWait();
 
  if(glide.getAnswer() == ''){
    $j('#gsft_main').attr('src','https://yourinstance.service-now.com/sys_user.do?sys_id=' +userID );
  }
}
}



it will look like this



find_real_file.png



let me know if u have any questions.



(mark helpful/correct/like if it helps)



Regards,


Rushit Patel


Hi Rushit,



That was so helpful and it is working


Thank you