Data table widget using macro variable

Akki1
Tera Contributor

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

 

1 ACCEPTED SOLUTION

Markus Kraus
Kilo Sage

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:
find_real_file.png

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 🙂

View solution in original post

18 REPLIES 18

Hi @Markus Kramer 

anything possible if i click the incident number details get opened up or it is redirected to native ui

 

Add this to the Client controller:

$scope.$on('data_table.click', function (event, params) {
		$location.search('id=form&table=' + params.table + '&sys_id=' + params.sys_id);
	});

Make sure to $location at the first line of the Client controller:

api.controller=function($scope, $location) {
	var c = this;
	// ...
};

 

Alternatively, if you want it to be opened with a PopUp, you can use this instead of the $location.search(...) (make sure to add spUtil in the first line of the Client controller😞

$scope.$on('data_table.click', function (event, params) {
	spModal.open({
		widget: 'widget-form',
		title: 'Incident',
		footerStyle: { border: 'none', 'padding-top': 0 },
		buttons: [],
		widgetInput: {
			table: params.table,
			sys_id: params.sys_id,
			view: 'sp',
			isPopup: true
		}
	});
});



I've used the first approach but I just wanna display the data but right now it is showing data in editable form and has save button. I don't want this ...I just want to display the contents

Add this onLoad script on the incident table (you might want to clone the ootb 'sp' view btw name it e.g. 'sp_readonly' - then you have to adjust the view name in the onload and in the widgetInput parameters):
Name: Hide All
UI Type: Mobile / Service Portal
Type: onLoad
Global: false
View: sp
Script:

function onLoad() {
	setTimeout(function() {
		var self = this;
		var angular = self.angular;
		var element = angular.element('.vfd1f4ec347730200ba13a5554ee490c0');
		var scope = element.scope();
		scope.data.hideRelatedLists = true;
		scope.disableUIActions = true;
		scope.getUIActions = angular.noop;
		scope.getPrimaryAction = angular.noop;
		var elements = element.find('.panel-footer');
		elements.hide();
	});
}

 

Is this a sys_id?

vfd1f4ec347730200ba13a5554ee490c0

I tried this script and it is not working