How to create Reset button in catalog item

Vaishnavi10
Tera Contributor

Hi Team,

I want to add a button in my catalog item as Clear Values and on clicking the button, it should clear the field values. 

Please help.

 

Thanks in advance.

11 REPLIES 11

Vaishnavi10
Tera Contributor

Hi Team,

 

Thanks for your reply. Actually my query to show the button on catalog item same as submit or order now button while raising the request.

Hi Vaishanvi,

Create a button type as  submit and write onSubmit Client script but instead of submit you can clear values. Add return false at the end in the code that i gave you.

Hi,

So are you saying you want to clear the values when user clicks on button in the catalog form during submission?

if yes then you need to use UI macro and button inside it and then clear all the variables for the current catalog item

Remember you will have to use macro with widget for portal to work

How to display UI macro in service portal catalog form

Regards
Ankur

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

Have you looked at the update from @Jaspal Singh ?

That links to a page explaining how to create a widget that contains a button.

 

Reset Button or Clear Values button widget to clear catalog item variable values

Step 1: Create a widget as shown below

Body HTML Template:

<button type="button" class="btn btn-danger btn-block" ng-click="c.setFieldValue(inputValue)">Reset Values</button>



Client Controller script


function($scope) {
    var c = this;
    c.setFieldValue = function (uploadname) {
        var g_form = $scope.page.g_form;
        g_form.clearValue("acrobat");
        g_form.setValue("Additional_software_requirements", "");
        g_form.setValue("test", "");
        g_form.setValue("photoshop", "");
    };
}

 


Step-2: Create a variable of type Macro and in the default section give this widget name.

Community Alums
Not applicable

Hi Vaishnavi,

Are you got solution for the same?

thanks,

Ganesh