Auto-Populate in Variable is not working using Service Portal but works in Technical View.

Jeck Manalo
Tera Guru

Hi Team,

 

I wonder why the auto-populate field is not working in portal view but working in technical view.

 

Hence im trying to create a onchange script to get the phone territory but its not working any idea how can I achieve this ?.

 

 

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

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

        return;

    }

    g_form.getReference('who_is_this_request_for', function(user) {

        if (user.location) {

     g_form.getReference(user.location, function(location) {

          if (location.parent) {

           g_form.getReference(location.parent, function(parentLocation) {

                    if (parentLocation.phone_territory) {

                            g_form.getReference(parentLocation.phone_territory, function(phoneTerritory) {

                                var ccc = phoneTerritory.ccc

                                var displayValue = '+' + ccc;

                                g_form.setValue('phone_number', displayValue);

                            });

                        }

                    });

                }

            });

        }

    });

}

 

 

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@Jeck Manalo 

it clearly means the user doesn't have read access to that referenced table and hence cannot bring the data.

you are doing multiple getReference with callback which is not good at client side.

Please use normal onChange + GlideAjax and use GlideRecord and see if that works fine.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Hi @Jeck Manalo 

 

Looks like the user doesn't have access for that table.

*************************************************************************************************************
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]

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

View solution in original post

7 REPLIES 7

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Jeck Manalo 

 

You an try the Auto-populate feature in Variable level where no code is required.

*************************************************************************************************************
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,

 

just figure out it work in technical view and portal view using admin account but its not working in normal account.

 

Any idea about this ?

 

JeckManalo_0-1739351114614.png

JeckManalo_1-1739351227801.png

 

Hi @Jeck Manalo 

 

What is normal account mean here? and when you not working means not populating valeue?

*************************************************************************************************************
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]

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

normal account means a user who will raise a request for the catalogs.

 

so in the screenshot i provided there is two different user where user that has no role or something and an admin user account.