Search-Now application

Some years ago I developed a windows frontend for ServiceNow’s Code search feature. This worked just fine. But technologies develop and I learn new stuff like Angular and PWA Progressive Web Aps.

So I decided to convert the windows app to a PWA. A website built with Ionic, Capacitor and Angular. This means it is truly cross platform compatible.

Configuration in ServiceNow

Newer instances do not have the search group “ServiceNow CodeSearch”. You can download that here.

Install on device.

The app can be installed on home screen. I do not have Android so cannot say exactly how it is done on these devices.

On iPhone and iPads open Safari and open the url: when loaded you can add the app to your home screen by clicking on the “Share” icon and selecting add to homepage. Done. Now you can run the app directly from you iPhone or iPad.

When navigating to the site in chrome on windows there is also an install app option in the “….” menu.

Site url:

Configure app

When the app is started first time you are directed to the tab to add instances.

Then click on NEW

and fill in the information then click on add.

You can edit, delete and copy instances by swiping to the left which reveals the buttons.

It is also possible to manually enter instances by editing the config file directly.

Click on

This opens a text field with the config file in json format. It is an array of objects.

For easy editing I suggest you user “copy to clipboard” and switch to an editor, edit the file then copy it and use “Past from clipboard” to insert the file again. Make sure the structure is correct. Formatting does not matter.

This is how the file should look like.

    "id": "e8a14f02-2290-43d6-a7a8-86d607b931fd",
    "name": "PDI",
    "url": "",
    "user": "userid",
    "password": "password",
    "cloudService": false

Swipe action on the instance list reveals buttons to delete, copy and edit an instance.

Note! Currently there is no warning when deleting.


You can now start searching. First select the instance, then group. (table not implemented yet) enter search term and click on search. Searching takes a little while but then the results are displayed. You can open each search result directly in ServiceNow by clicking on the OPEN link.

Updating app

When a new version is available a popup appear and you can update the app to the latest version.

More screenshots

Which WYSIWYG editor to use in ServiceNow?

In the last two projects I have worked on the TinyMCE editor plays a huge part of the applications I developed for the Service Portal (a dynamic pdf generator and a new email client supporting secure emails).

I found the editor to be very difficult to customize and prevent it from altering the html content. The latest issue I have encountered is an issue with new lines. The editor inserts either P or BR. The problem is that when BR is inserted it is the version <br /> and we found that in rare cases this can actually lead to loss of editor content.

So I am looking for alternative editors for future projects.

So far I have tested following alternatives very briefly. The tests consists of only a few things so far:

  • Can I instantiate the editor and edit content?
  • Can I get the content via event when user has modified it?
  • Can I set the content for example when user clicks a button?
  • Can I insert images from clipboard

TinyMCE 5CommercialNoNot
CKeditor 5Commercial NoUnable to
Froala 4Commercial YesEasy pdf

I still need to do more thourough testing but I kind of like Froala.

As for TinyMCE 5. This seems like the obvious choice since ServiceNow is already using version 4. However version 5 requires the page to be rendered in standards mode and that is not the case in ServiceNow.

Do You know any editors that will work in Service Portal or as a component in Now Experience Framework ?

If you do please comment below or send me a message on LinkedIn.

Widget became slow after upgrading from Paris to Quebec

Applies to Quebec and Rome releases.

Yesterday I learned something surprising about Service Portal Widgets. Maybe other developer already know this but it was a surprise to me. Even after I have worked with the new Service Portal since it was released. The problem first appeared after upgrading my PDI to Paris and Rome.

I am building a service portal application with multiple widgets that communicate via angular service. So when a button is clicked in one widget a message is sent and the other widgets acts accordingly for example by showing or hiding information etc.

I started this on a Paris PDI before Quebec was released and everything was fine. Then because of other work I did not continue working on this until after my PDI was upgraded to Rome. Then the problem appeared. Now one (out of 10) widgets suddenly reacted very slowly on messages. The html would not update immediately, it could take up to about one minute.

I spent many hours debugging, commenting code out etc to try to isolate what was causing this. Then finally I found the answer in a stackoverflow question that mentioned $scope.$apply(). I had never heard about this and never seen it used in a OOB widget. It is used in about 10 widgets.

The AngularJS documentation says

$apply() is used to execute an expression in AngularJS from outside of the AngularJS framework.


So of course I immediately tried to add this simple line of code and voila the widget in question updated fast again. A simple solution that took many hours for me to discover.

Consider following code in the client controller part of a widget. This code subscribes to a service and wait for a specific message. When that message arrives it updates a variable in $scope that is displayed in the html with the {{}} binding syntax.

$(document).ready(function () {

  var removeListener = someService.addListener(function (action) {

    if (action.action == 'doSomething') {
      $scope.field = action.someData;



Without the $scope.$apply() the update of html can take as long as one minute when running on Quebec or later releases. With the line it is updated immediately.

I have confirmed that Quebec introduced changes to the Service Portal that makes this necessary. I confirmed by loading my application on a Paris PDI and ran the widget without the $apply() and it worked as expected with no delays. Then I upgraded the PDI to Quebec and made no changes to the widget but now it was extremely slow. Then I added the $apply() and the widget worked fast again. To re-confirm I upgraded the PDI to Rome and the same would happen.

So the question is when to use $apply. Well the documentation says whenever you update $scope outside a digest. A simple way to find out is just to add it whenever you make updates to $scope. If it is not necessary then you will get an error message in the console.log stating that code is already running in digist so $apply() is not required.

As I mentioned this code is not widely used in OOB Widgets which is why I never ran into this. I usually go check out new widgets when a new release is available to learn about new stuff in the portal.

Containerizing MID Server

From Rome release it is now possible to run MID servers in containers.

This means maintaining and deploying extra MID servers now can be done very fast.

Official documentation HERE.

In the old days setting up multiple MID servers on the same host would require going through the installation multiple times. Now you just build the MID server image one time for the relevant ServiceNow release and push it to a repository such as Docker Hub.

In the following I will describe how I setup an image for running multiple MID servers.

Step one: Download the correct recipe from your ServiceNow instanse. I choose the linux recipe as I could not get the windows recipe to work. It might be an issue only with the first release of Rome.

Step two: Unzip the downloaded zip-file and maybe rename / move to a suitable folder.

Step three: Build. Now begins the fun stuff. My preferred way is to open the folder with Visual Studio Code, then open a terminal window. You can also open a command prompt or powershell window.

Then run the command: docker build . –tag dockerid/midserver-rome

Replace ” dockerid ” with your docker hub id if you want to push the image to the hub.

Building first time will take a while so go grab a cup of coffe and enjoy the fact that your are going to save time setting up mid servers in the future 🙂

Step four: Setup an env file with the parameters to start the MID server so it can connect to your instanse.

Filename: mid1.env

Add following parameters in the file and save:

MID_INSTANCE_USERNAME=userid setup with mid server roles
MID_INSTANCE_PASSWORD=password for userid
MID_SERVER_NAME=the name you see inside ServiceNow

Step five: Run. Then you can start the MID server with

docker run –env-file mid1.env dockerid/midserver-rome

After a few minutes you can see the server in serivcenow. You validate it the usual way.

To run a second mid server just copy mid1.env to mid2.env and adjust the server name then run the container agian with this file as env file instead.

Step six: Push to docker hub.

First login with docker login

Then run docker image push dockerid/midserver-rome

And now you can run it on other hosts.