Getting multiple calls via GlideAjax

Community Alums
Not applicable

HI Team,

 

I have written a onChange Client script on a catalog item as below:

The requirement is If the loggedin Person is having role as Supplier then we are firing this glideAjax and client script to check the company and thereby it should populate the Vendor Category.

Ankur20_0-1743572496547.png

Below is the Script include which is called via GlideAjax:

Ankur20_1-1743572587091.png

 

The issue is if you see gs.info('users are:'+user.getRowCount())

This is being printed multiple times.. I am not sure why?

Ankur20_2-1743572917456.png

 

Please assist in solving this?

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

Few things to check

1) your client script runs on change of vendor_category and you are setting the value again to same variable and hence it's causing multiple Ajax calls

2) why are you returning JSON string? simply return the array as this return arr.toString()

3) the table which you are querying with the company, is the field name "vendor" correct and is that field referring core_company table? what's the field type for that?

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

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

Few things to check

1) your client script runs on change of vendor_category and you are setting the value again to same variable and hence it's causing multiple Ajax calls

2) why are you returning JSON string? simply return the array as this return arr.toString()

3) the table which you are querying with the company, is the field name "vendor" correct and is that field referring core_company table? what's the field type for that?

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

Akiladevi Raje1
Giga Guru

Hi @Community Alums 

 

Add the info logs below this.getParameter('sysparam_user') line and log the supplier variable, use the  

 

var gUser = new Gliderecord('sys_user');

gUser.get(supplier);

if(gUser.company)

{

//add another glide record

}