Before London release, it was very easy to get that link. You had to go MidServer and Downloads and copy the link for the appropriate operating system. And you could use it as an address for your curl command.
Continue reading How to get a URL to download Mid Server installerHow to display knowledge base hierarchy
Recently I was asked by Knowledgebase Manager why she was not able to remove an unnecessary category in ServiceNow. The answer was simple: there is an ACL which checks if a category has a child, either article or other category. We found a retired article which was still linked to this category. Because of that, it was impossible to delete this category.
Continue reading How to display knowledge base hierarchyError: “sc_req_item_stageGetChoices” is not defined.
A few days ago I found a really weird bug while I was writing a small application in ServiceNow. I noticed following warning in logs:
org.mozilla.javascript.EcmaError: "sc_req_item_stageGetChoices" is not defined. Caused by error in sys_script_include.0236e5eddbd22300b5919fd2ca9619c2.script at line 223
Continue reading Error: “sc_req_item_stageGetChoices” is not defined.
JavaScript Automatic semicolon insertion in case of return
Today I’m going describe something not directly related to ServiceNow. But JavaScript is our language and we use it almost every day. The issue I’m going to write about might be weird for you if you have some background in languages like Java or C#.
Let’s write some simple code:
function getObject(){ return{ param: 5 } } var myObject = getObject(); gs.print(myObject.param);
Continue reading JavaScript Automatic semicolon insertion in case of return
ATF – Database View to summarize information about Test Suits, Tests and Test Steps
Recently I was asked for providing report with summary information about configured tests.
I’ve created a Database View to have it ready for the future requests (I’m expecting that sooner or later I’ll be asked again for the same).
The scheme is very simple:
The update set with this Database View:
Download
How to start with TDD in ServiceNow
This time I would like to present how to create very first unit test and adapt TDD for creating scripts in ServiceNow.
I’m going to create two very simple script includes: Course and Student.
The course will be implemented three methods:
– addStudent
– getStudent
– removeStudent
How to install MidServer on Linux hosted on VirtualBox
In this article I’m going to show how you can install MidServer on linux (CentOS7) using for that VirtualBox.
I’ll skip the VirtualBox installation. During the Centos installation you can choose default values if it’s not mentioned differently.
Continue reading How to install MidServer on Linux hosted on VirtualBox
How to get a list of all roles assigned directly and indirectly (inherited) to group
List of roles assigned to group
Some time ago I needed to retrieve complete list of roles assigned to group from ServiceNow. I wanted to know which roles were granted by which group. I quickly found out that there is no easy solution for roles that are inherited from other roles. I prepared script (can be execute in Background Script or in Fix Script) which helped me to retrieve this list:
function checkIfGroupHasRoles(groupRecord){ var grGHR = new GlideRecord('sys_group_has_role'); grGHR.addQuery('group', groupRecord.sys_id); grGHR.query(); return grGHR.hasNext(); } function checkIfRoleContainsRoles (checkingRole){ var grRC = new GlideRecord('sys_user_role_contains'); grRC.addQuery('role.name',checkingRole); grRC.query(); return grRC.hasNext(); } function getArrayOfChildRoles(parentRole){ var grRC = new GlideRecord('sys_user_role_contains'); grRC.addQuery('role.name',parentRole); grRC.query(); var resultArray = []; while (grRC.next()){ var childRole = grRC.getDisplayValue('contains'); resultArray.push(childRole.toString()); if( checkIfRoleContainsRoles(childRole) ){ var arrayOfChildRoles = getArrayOfChildRoles(childRole); resultArray = resultArray.concat(arrayOfChildRoles); } } return resultArray; } function getArrayOfAllRolesForGroup(groupRecord){ var resultArray = []; var grGHR = new GlideRecord('sys_group_has_role'); grGHR.addQuery('group', groupRecord.sys_id); grGHR.query(); while(grGHR.next()){ var role = grGHR.role.name; resultArray.push(role.toString()); if ( checkIfRoleContainsRoles(role) ){ var arrayOfChildRoles=[]; arrayOfChildRoles = getArrayOfChildRoles(role); resultArray = resultArray.concat(arrayOfChildRoles); } } return resultArray; } function printRolesForGroups(){ var grGR = new GlideRecord('sys_user_group'); grGR.query(); while (grGR.next()){ if ( checkIfGroupHasRoles( grGR ) ){ var arrayOfAllRolesForGroup = []; arrayOfAllRolesForGroup = getArrayOfAllRolesForGroup(grGR); var au = new ArrayUtil(); arrayOfAllRolesForGroup = au.unique(arrayOfAllRolesForGroup); var message = grGR.getDisplayValue() + ': ' + arrayOfAllRolesForGroup.join(','); gs.print(message); } } } printRolesForGroups();
Calendar Report as URL link with default highlighted field
In this post I’m going to present how to create simply report calendar. Next how to enable this report as a module with predefined field for ‘Highlight based on’
Continue reading Calendar Report as URL link with default highlighted field
Testing ServiceNow Rest Api using CURL
Sometimes you can find very helpful to leave rest api explorer in ServiceNow and use some external tools like Postman or Curl to send some request to your instance. In this post I’m going to present some functionalities of curl.
If your OS is Windows you have to download curl from: https://curl.haxx.se/
Or you can use Git Bash: https://git-scm.com/download/win