Add a button in the widget Data Table from Instance Definition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 04:04 AM
I am using a cloned version of the widget "Data Table from Instance Definition".
How can I add a button and place it either in front of the Keyword Search or to the right of filter?
My Button shall have the same functionality as the Link button widget, but I don't know how to place it where I want it.
I can place it within the Page, but then I think it takes up too much space and messes up the view a bit. The best is to place it to the right of the filter.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 10:43 AM
Hi,
You can add this to client script of that widget, added 2 seconds to wait for widget to show up.
setTimeout(function(){
var searchDOM = document.querySelector('form[ng-if="data.hasTextIndex"] div')
searchDOM.insertAdjacentHTML("beforebegin", "<div class='btn btn-primary stying'>My button</p>");
},2000);
and add stying class in CSS to make it pretty
Cuong Phan
ServiceNow Technical Lead
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 11:00 PM
Thanks for your reply.
Did you add your code in the Data Table widget or in the Data Table from Instance definition?
I added it in Data Table from Instance definition, and the button does not show.
//Tor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2020 01:52 AM
Hi,
To my previous question, I now added it in the Data Table widget and it shows. I even styled it to look like a link.
Next challenge is to get this button to open up a specific knowledge article in my instance.
I have tried to insert ng-href in your code without luck.
//Tor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2020 09:57 AM
Hi,
Please try this instead
searchDOM.insertAdjacentHTML("beforebegin", '<a class="btn btn-primary" href="/yourURL" target="_blank" >My button</a>');
Cuong Phan
ServiceNow Technical Lead