Clear Variables on Form when "Add to Cart" is clicked

Surya_Prakash
Tera Contributor

Hi All,

 

We have a requirement to clear some variables on the form when all the variables were filled and clicked on "Add to Cart". So that those values should be filled again before adding the form to cart again. Is there any way to achieve this using any scripts?

 

Thanks,

Surya. P

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi,

This would need more of DOM manipulation. You can check for links that has solution

1. To clear all

2. To clear specific variables

Hi @Jaspal Singh,

 

Thanks for the reply. I had already tried both the solutions and it is throwing a "Java Error Console" error on the portal. And when I tried to Inspect it, it is showing that getElementById is not readable. And also I read that document.getElementById is not recommended by ServiceNow since it is an DOM Manipulation. Is there any other way to achieve this solution?

Surya_Prakash
Tera Contributor

Is this possible to clear values?

Fazal Mohammad
ServiceNow Employee
ServiceNow Employee

Hi @Surya_Prakash 

Did you tried g_form.clearValue(fieldNameHere) in UI Action's script?

Ex : g_form.clearValue('amount');

 

Please mark this helpful and accept the solution, if it worked for you.

 

Thanks

Fazal