The Zurich release has arrived! Interested in new features and functionalities? Click here for more

AM_Guy
Tera Contributor

We created a UI Action that adds a Bookmark to the Edge.   We had some discussion on whether or not Tagged Documents would fulfill this need, and we felt this solution provided enough value that we went ahead and built it.   Though Tagged Documents is pretty cool.

Our solution uses a UI Action with a client script so we could do a page refresh.   You could also do it as a non-client UI Action, but the user will have to refresh the page manually for the bookmark to show up.

Here is what we wanted to accomplish

AddNewBookmarkHere.jpg

UI Action Details

Name: Add Bookmark

Table: Task

Action Name: add_bookmark

Client: True

Form context menu: True

Onclick: addBookmark();

Script

function addBookmark(){

          var ga = new GlideAjax('AM_Client_Scripts');

          ga.addParam('sysparm_name','insertRecordBookmark');

          ga.addParam('sysparm_sys_id',g_form.getUniqueValue());

          ga.addParam('sysparm_class_name',g_form.getTableName());

          ga.getXML();

       

          //This refreshes the whole page so the bookmark appears, we felt it gave a better user experience

          window.top.location.href = "/nav_to.do?uri=" + g_form.getTableName() + '.do?sys_id=' + g_form.getUniqueValue();

}

This UI Action relies on the following Script Include.   See this wiki article for more details: GlideAjax - ServiceNow Wiki

Name: Custom_Add_Bookmark

Client Callable: True

Script

var Custom_Add_Bookmark = Class.create();

          Custom_Add_Bookmark.prototype = Object.extendsObject(AbstractAjaxProcessor, {

                              insertRecordBookmark: function () {

                              var sysId = this.getParameter('sysparm_sys_id');

                              var className = this.getParameter('sysparm_class_name');

                              var record = new GlideRecord(className);

                              if(record.get(sysId)){

                                        var bookRec = new GlideRecord('sys_ui_bookmark');

                                        bookRec.pinned = "true";

                                        bookRec.user = gs.getUserID();

                                        bookRec.order = "900"; //I was a little lazy with the order

                                        bookRec.title = record.number;

                                        bookRec.url = className + ".do?sys_id=" + sysId;

                                        bookRec.icon = "icon-star color-blue";

                                        bookRec.flyout = "true";

                                        bookRec.insert();

                                }

                          return;

                          }

            });

After applying this, I can go to any record on any table that extends the Task table, right-click on the header, click Add Bookmark, and the record will be available on the Edge.

AddBookmarkUIAction.jpg

I enjoy using it to keep whatever record I'm working on at the moment readily available.