Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to create a custom button on Service Portal

Hari1
Mega Sage

Hi,

I have a requirement to remove the existing "Submit" button on the portal and add a custom "Calculate" button on the service portal. I have a couple of fields on the record producer and once all the field values are filled and i click on the calculate button the i need to fill in couple of fields with the calculated value.

Currently i am able to achieve this using the catalog client script. But i need this to be done by using the calculate button.

Below is the existing client script. I am new to Portal and I have seen couple of blogs that says that we could achieve this using the portal widget but i have sure how that can be done.

var hours = 36;
var material = 28;
	
var labour = hours * 2;
var overHead = hours * 2;
	
var licence = parseInt(g_form.getValue('lic_cost'));
var fulfiller = parseInt(g_form.getValue('fulfiller'));
var support = parseInt(g_form.getValue('support'));
var totalServer = parseInt(g_form.getValue('total_servers'));
	
var overHead = (labour + material + overHead) * 12 * (licence + fulfiller + support + totalServer);
	
g_form.setValue('overhead_cost',overHead);

 

Thanks.

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello Hari,

1) Create a custom type variable in your record producer 

 

find_real_file.png

2) Then create  a widget and tag it to a "Custom" type variable like below 

 need  to tag this widget in the custom variable that you have created

find_real_file.png

Widget Code:

<div>
  <button  type="button" class="btn btn-info btn-block" ng-click="calculateValue()">Calculate</button>

</div>

Client Controller:

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

	c.calculateValue = function() {
var g_form = $scope.page.g_form;
var hours = 36;
var material = 28;
var labour = hours * 2;
var overHead = hours * 2;
	
var licence = parseInt(g_form.getValue('lic_cost'));
var fulfiller = parseInt(g_form.getValue('fulfiller'));
var support = parseInt(g_form.getValue('support'));
var totalServer = parseInt(g_form.getValue('total_servers'));
	
var overHead = (labour + material + overHead) * 12 * (licence + fulfiller + support + totalServer);
	
g_form.setValue('overhead_cost',overHead);
			

		
	};
};

Please mark my answer correct if it helps you

 

View solution in original post

10 REPLIES 10

Thanks Mohith.