Need to cancel submit a form using glide ajax

amit164
Giga Contributor

when a user enter a short description which is already exists,then form submission should aborted.

i am using on submit client script and glide ajax.

all i want to cancel sumission on the basis of result from script include.

how is it possible plz suggest

1 ACCEPTED SOLUTION

Hi,

If you used same then you should mark my response as correct.

But anyway what important here is solution to your query and you got that.

Thanks,

Dhananjay.

View solution in original post

14 REPLIES 14

Hi Amit,

Any Update on these?

Please mark if above post helps you in any way to solve your problem!

thanks for suggestion i used sync to achive the result 

thank for supporting

Dhananjay Pawar
Kilo Sage

Hi,

In addition to above and Priya mentioned if you use asynchronous call in onSubmit client script. Client script does not wait for response from server it submits the form. Still you want this in onSubmit client script you can use synchronous call.

Find below code.

onSubmit client script -

 

function onSubmit() {
var userVal=g_form.getValue('short_description');
var ga = new GlideAjax('checkShortDescriptionSI') ;
ga.addParam('sysparm_name','checkShortDesc');
ga.addParam('sysparm_user_name',userVal);

ga.getXMLWait();
var value1=ga.getAnswer();

if(value1=='true')
{

return false;
}
else{

return true;
}

}

 

script include code-

 

script include name - checkShortDescriptionSI

client callable - true/checked

 

var checkShortDescriptionSI = Class.create();
checkShortDescriptionSI.prototype = Object.extendsObject(AbstractAjaxProcessor, {

checkShortDesc: function() {

var gr=new GlideRecord("incident");
gr.addQuery("short_description",this.getParameter('sysparm_user_name'));

gr.query();

if(gr.next())
{

return true;
}
else{
return false;
}
}

});

 

Mark correct and helpful based on impact.

Thanks,

Dhananjay.

thank i achieved that with same kind of appoach by synchronous instead of async.

thank u for your suggestion

Hi,

Glad you got your answer, May I know which script did you used?

Thanks,

Dhananjay.