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

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

 

 

 

 

Community Alums
Not applicable

this is worked for me thanks, Possible to add condition from filter to exclude few fields.   

Mohith Devatte
Tera Sage
Tera Sage

@Ganesh Palve  please check my above response and let me if the widget is working or not on the portal i made few change to the client controller script

Community Alums
Not applicable

Hi Mohit

button is showing but its not working

@Ganesh Palve 

Can you share your widget code?