Logged in requested for details auto populate

zeerodger27
Tera Contributor

I have written the below catalog client script, when the requested for field has changed the city, state, location has to be populated, but how to populate the current logged in user details for the same fields?

 

OnChange Catalog client script

function onChange(control, oldValue, newValue, isLoading) {

   if (isLoading || newValue == '') {

      return;

   }

 

var ga = new GlideAjax('User');

    ga.addParam('sysparm_name', "checkRecordPresent");

    ga.addParam('sysparm_userID', g_form.getValue('requested_for'));

    ga.getXMLAnswer(function(answer){

        if(answer != 'not found'){

            var parser = JSON.parse(answer);

            g_form.setValue('req_manager', parser.u_reference_1);

            g_form.setValue('location', parser.location);

            g_form.setValue('city', parser.u_city);

            g_form.setValue('state', parser.state);

           

        }

    });

   //Type appropriate comment here, and begin script below

   

}

 

9 REPLIES 9

Dr Atul G- LNG
Tera Patron
Tera Patron

HI @zeerodger27 

 

You can try with Auto Populate feature on catalog variable.

 

LearnNGrowAtul_0-1707998216202.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG 

Thanks for the reply, it is working but how do I achieve it with my script? Any mistakes in my script?

Sorry @zeerodger27 

My hands are tight in script so tough for me to get the error here. OOTB i know. 🙂

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Kishor O
Tera Sage

Please share your script include code as well , we can identify the error