
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 04:03 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 03:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 05:44 AM
Hi Abdul,
Are you saying you are getting difficulty in passing the catalog variable values to ui page or issue during inserting record in the target table in the ui page?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 10:34 PM
Ankur,
Let me explain you what i did,
I created a button widget on SP now when the user enter all the variable details and click that widget i:e. Button then all the value need to captured which is not happening.
I hope you got my point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 01:28 AM
Hello Azeez,
I think this might help you.
So, I created a button on the catalog item form as shown in the below image.
So now when the user clicks that button then the variable value(hellio) is getting copied into the another table i.e to the problem table.
I used the ui macro script below is the script:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<input type='button' value ='Button' onclick="button1()"></input>
<script>
function button1(){
var kbcreate = new GlideRecord('problem');
alert('calling gliderecord');
kbcreate.initialize();
var call = g_form.getValue('test')
alert(call);
kbcreate.short_description = 'Create value in KA' /// This is working since its a static value
kbcreate.description = call;
kbcreate.insert();
}
</script>
</j:jelly>
I think this might help you.
Regards,
Ajay.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 02:27 AM
Hello Ajay,
Glad to see your response
But UI Macro doesnt work in Service Portal, i am trying it using AngularJS

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 03:02 AM
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