How to reload form in glide ajax ?

Serhii5
Mega Guru

Hi guys, i have glide ajax script and it works fine, but I have a problem with reloading form from script include, or in ui action but after glide ajax finished, how is it possible? 

1 ACCEPTED SOLUTION

Hi,

can you try this

// ui action
function moveToCloseState() {
    var sys_id = g_form.getUniqueValue();
    var ga = new GlideAjax('incident');
    ga.addParam('sysparm_name', 'setCloseState');
    ga.addParam('sysparm_id', sys_id);
    ga.getXML();

   var url = '/' + g_form.getTableName() + '.do?sys_id=' + sys_id;

   top.location.href = url;
}

Regards
Ankur

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

View solution in original post

9 REPLIES 9

Chuck Tomasi
Tera Patron

This brings up all kinds of questions in my mind. What is the use case you are trying to accomplish? What's the business requirement? 

Noting that GlideAjax happens async, updates info on the form makes me wonder why the form needs to be reloaded, or why you are using GlideAjax if you need the form refreshed for some other reason. The Async nature of GlideAjax also makes it difficult to know when to actually refresh.

Can it be done, I'm sure there's a way. SHOULD it be done, or is there a better way requires more understanding of the context of what you are trying to accomplish (beyond what you posted above.)

Thanks.

Hi Chuck, thanks for your answer, I have no state field on the incident form, and I need to move incident in the close state with UI Action, I'm using glide ajax to pass a parameter of my form, in the script include I'm using update() method and I see all changes only after reloading the form, to do my form more user friendly, i would like to reload after state changed;

krishnakumar2
Tera Guru

You can try using location.reload();

Hi, thanks for your answer, still doesn't work