GlideAjax with no response needed

JJG
Kilo Guru

Hello,

I have a client script that calls a script include. I don't need a response from the script include to be returned to the client script. How can I just execute the GlideAjax? should I just add a query() at the end? (See code below)

var gaFirst = new GlideAjax('createOnboardingUser');
gaFirst.addParam('sysparm_name', 'create_user');
gaFirst.addParam('sysparm_first', first);
gaFirst.addParam('sysparm_last', last);
gaFirst.addParam('sysparm_email', email);
gaFirst.addParam('sysparm_manager', manager);
gaFirst.addParam('sysparm_title', title);
gaFirst.getXMLAnswer(_handleResponse2); // Should I change this to gaFirst.query(); I dont need the GlideAjax to return a response, I just need it to execute

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

if you don't want anything to be returned then from script include you can have the function with no code inside it

function _handleResponse2(answer){

// do nothing

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi JJG,

Can you share how your Script Include looks like? And is the create_user function in your Script Include reached at all?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

if you don't want anything to be returned then from script include you can have the function with no code inside it

function _handleResponse2(answer){

// do nothing

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

DirkRedeker
Mega Sage

Hi

 

Have a look at the following article:

https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...

You will need the "response" function, but you can leave it empty.

Let me know, if that answers your question.

BR

Dirk

 

Kunal Varkhede
Tera Guru

HI,

 

In script include function don't do anything 

create_user : function()

{

return "";

}

 

In client side do this

var gaFirst = new GlideAjax('createOnboardingUser');
gaFirst.addParam('sysparm_name', 'create_user');
gaFirst.addParam('sysparm_first', first);
gaFirst.addParam('sysparm_last', last);
gaFirst.addParam('sysparm_email', email);
gaFirst.addParam('sysparm_manager', manager);
gaFirst.addParam('sysparm_title', title);
gaFirst.getXMLAnswer(_handleResponse2);

function _handleResponse2(response)

{

var answer= response;

}

 

Thanks,

Kunal