How to add "Reset" button for clear values of variable in service Catalog form.

Community Alums
Not applicable

I want to add button on service catalog form ---> "Reset", which will clear all variables values.

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @Ganesh Palve ,

you can create a custom type variable and tag your widget in that variable which will render the button on the catalog form 

find_real_file.png

find_real_file.png

 

please try below code in the widget 

Html:

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

Client controller:

api.controller=function($scope) {
	/* widget controller */
	var c = this;

	c.clearValue = function() {
		alert('test');
		var g_form = $scope.page.g_form;
		
	

			var allFields = g_form.getFieldNames();
		alert(allFields);

			for(var fieldName in allFields){
			

				g_form.setValue(allFields[fieldName],'');

			

		}
	};
};

Please try this and if it works please mark my answer as correct

 

 

 

 

View solution in original post

14 REPLIES 14

Adam Robbins1
Mega Guru

Hi Ganesh,

If the user refreshes the browser it wipes all the fields so the form can be started over. 

Thanks,

Adam

Community Alums
Not applicable

Hi Adam,

Thank your response but I want button over the form.

Thanks,

Ganesh

 

Yousaf
Giga Sage

Hi Ganesh,

Check this link please 

https://community.servicenow.com/community?id=community_question&sys_id=ba4bb2fbdb239810fa192183ca96...

 

Mark Correct or Helpful if it helps.


***Mark Correct or Helpful if it helps.***

Community Alums
Not applicable

Hi Yousaf,

Thank you for your response, I already review that link but macro variable type is not available in Rome Or San Diego version.

Thanks,

Ganesh