How to prevent reloading the page multiple times in workspace

Kiran29
Tera Contributor

Hi,

I am using the below server script and client script within UI action, is there a way I can prevent reloading the page multiple times. Actually want to reload only when first if statement is true. 

Thanks,

 

Server script:

 
var util = new KeywordRoutingUtil();
var result = util.evaluateRouting(current);
if (result.abort) {
gs.addErrorMessage(result.message);
gs.setRedirect(current);
} else {
//current.update();
gs.setRedirect(current);
current.insert();
}

Client Script:

function onClick(g_form) {
    g_form.submit('save_action');
    g_form.reload();
}