Issue with Form resubmission using g_form.submit in catalog item

saikatmitra
Tera Contributor

g_form.getControl('order_now_button').click(); is not working on me. Can you give me an alternative. g_form.submit is working for portal but not for catalog item CMS. I want some alternative of g_form.submit which works in both.

 

Here is the callback function. Please help

 

function HelloWorldParse(response) {
if(ans1 =="success")
{
g_form.setValue('check_flag', 'true');
g_form.submit();
}
else{

alert("No field values have changed");
g_form.clearValue('application_name');
g_form.clearValue('type_of_operation');
return false;
}
}

1 ACCEPTED SOLUTION

@saikatmitra 

Isolate script = false will allow DOM to work in native.

Keep it false as you have already kept it

Try this and it should work fine for native

if(ans1 =="success")
{
g_form.setValue('check_flag', 'true');

if(window == null){

// portal
g_form.submit();

}

else{

// native

$j("#oi_order_now_button").trigger('click'); // for catalog item

$j("#submit_button").trigger('click'); // for record producer

}
}

Regards
Ankur

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

View solution in original post

18 REPLIES 18

For Service Portal it is working fine but for catalog item I am getting one error like below  but these functions are also not working for me. I want somthing which works for both Portal and CMS.

 

The g_form.submit function has no meaning on a catlog item. Perhaps you mean g_form.addToCart() or g_form.orderNow() instead

@saikatmitra 

please try this

if(ans1 =="success")
{
g_form.setValue('check_flag', 'true');

if(window == null){

// portal
g_form.submit();

}

else{

g_form.orderNow();

}
}

Regards
Ankur

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

I don't think there is orderNow function in g_form. 

On which action , you are trying to submit the form? and when submitting what functionaltiy are you expectinng? Is it order now or add to cart?

Hi,

I could see something like this

find_real_file.png

Regards
Ankur

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

Ah okay.. but unfortunately it is not mentioned anywhere in the API.

@saikatmitra can you try using those functions and check once.