- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 05:29 AM
Hi Priyanka,
i have used the Data table widget using macro variable. i am seeing result like below.
i am getting any table view, Please let me know if missed anything.
Or can you help me to create some custom widget to display table records and use it in catalog variable
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 10:52 AM
I think this is related to your "hide submit" button post (please close the thread if you have found a solution)?
https://community.servicenow.com/community?id=community_question&sys_id=aeaf6d5d1b374990c17111751a4bcbc3
I guess in this case you want to go with the custom widget solution. The Widget is down below, here is an example of how this will look like:
Name: My Incidents
Body HTML Template:
<div>
<sp-widget widget="data.widget" />
</div>
Server script:
(function() {
data.widget = $sp.getWidget('widget-data-table', {
table: 'incident',
filter: 'assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe' // <Assigned to> <is dynamic> <Me>
});
})();
If you want a different filter, simply go to incident.list use the filter and then right click on the breadcrumbs: "Copy query" and paste this query in the server script.
Please let us know if this solved your problem 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 06:10 AM
Hi Akki,
Create a new custom widget, that simply creates an instance of the data-table widget with your options, and set that new custom widget in your macro.
Look at the Data Table from Instance Definition widget to see how they do the same thing.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 10:52 AM
I think this is related to your "hide submit" button post (please close the thread if you have found a solution)?
https://community.servicenow.com/community?id=community_question&sys_id=aeaf6d5d1b374990c17111751a4bcbc3
I guess in this case you want to go with the custom widget solution. The Widget is down below, here is an example of how this will look like:
Name: My Incidents
Body HTML Template:
<div>
<sp-widget widget="data.widget" />
</div>
Server script:
(function() {
data.widget = $sp.getWidget('widget-data-table', {
table: 'incident',
filter: 'assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe' // <Assigned to> <is dynamic> <Me>
});
})();
If you want a different filter, simply go to incident.list use the filter and then right click on the breadcrumbs: "Copy query" and paste this query in the server script.
Please let us know if this solved your problem 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 11:44 PM
Hi
Thanks for the help.
Just wanted to know if we can give the filter conditions dynamically i.e based on some field value chosen or something. if yes can u pls explain.
And also how can we display the columns of our choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 12:52 AM
Here you go:
HTML remains unchanged
Server script (add the columns comma-separated in 'fields'):
(function() {
data.widget = $sp.getWidget('widget-data-table', {
table: 'incident',
filter: 'assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe',
fields: 'number,short_description,description'
});
})();
Client controller:
api.controller=function($scope) {
var c = this;
var baseFilter = 'assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe';
var g_form = $scope.page.g_form;
$scope.$watch(function () {
return g_form.getValue('short_description');
}, function (newValue) {
setFilter(newValue, g_form.getValue('description'));
});
$scope.$watch(function () {
return g_form.getValue('description');
}, function (newValue) {
setFilter(g_form.getValue('short_description'), newValue);
});
function setFilter(shortDescription, description) {
var filter = baseFilter;
if (shortDescription) {
filter += '^short_descriptionLIKE' + shortDescription;
}
if (description) {
filter += '^descriptionLIKE' + description;
}
$scope.$broadcast('data_table.setFilter', filter);
}
};
Result: