What is best way to get Server-Side information on a Catalog Client script

Ashish Kathait
Tera Contributor

I have a Catalog Client Script which need to pull information from a Server-side table, and I have two ways to do that one is through Script include call and second is call back function.

 

What would one to use and which is better.

 

Call back function example - 

 

var ga = new GlideAjax('MyScriptInclude');
ga.addParam('sysparm_name', 'getDetails');
ga.addParam('sysparm_user_id', userId);
ga.getXMLAnswer(function(response) {
var data = JSON.parse(response);
g_form.setValue('my_field', data.some_value);
});

2 REPLIES 2

palanikumar
Mega Sage

Hi,

Do you mean option between call back and without call back function?

My recommendation is to use call back function as Service Portal supports only the GlideAjax with call back function

 

Thank you,
Palani

pavani_paluri
Giga Guru

Hi @Ashish Kathait,

Please see below table for detailed comparison of both callbacks:

 

getXMLAnswerYou want a clean, simple valueEasy, reusable
getXMLYou want more complex logic or XML parsingFlexible

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P