How to create a Button on Catalog item

AbdulAzeez
Mega Guru

Hello Everyone,

We have a requirement where we need to create a Button on Catalog item once the user enter details once the user click on the button it should redirect to some 'x' table and write those records.

It should work on Catalog & as well as Serive Portal

1 ACCEPTED SOLUTION

Hello Azeez,



I have tried below code in Serviceportal and it worked for me.



HTML:



<input type="text" name="name" ng-model="inputValue" />


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



Client Controller:



function($scope) {


var c = this;


c.setFieldValue = function(uploadname) {


var g_form = $scope.page.g_form;


if (g_form.getValue('a1') != '') { // a1, a2 Replace with your variable names


g_form.setValue('a2', g_form.getValue('a1'));


g_form.clearValue('a1');



}


else {


g_form.setValue('a2', $scope.inputValue);


$scope.inputValue = '';


}


}



Reference:


Service Portal: Catalog Item Buttons — ServiceNow Elite



Thank You


Srikanth


View solution in original post

10 REPLIES 10

That helped Sri...!



Thank you