Monday, January 27, 2020

ServiceNow Major upgrade

ServiceNow every year releases 2 major versions and it is important to upgrade your ServiceNow implementation so that it remains supported as well as your organisation can benefit from the latest features included in the newer releases.


Based on the size of instance and customization generally a major upgrade cycle will take from 4 -8 weeks. 


Review the release notes and if you have sandbox instance available , use it for the first look and analyse upgrade impact on existing functionality and size out the efforts required to action the skip logs. 

ServiceNow docs site has 7-phase plan upgrade checklist Here is a good starting point planning the upgrade cycle.


The key points from the above checklist include:


  1. Prepare project plan
  2. Prepare test plan
  3. Identify key stakeholders, power users, tests
  4. Identify interfacing teams and environments
  5. Identify the instances to upgrade
  6. Agree on issue tracking mechanism

Dev/Test instance upgrade , shakeout , skip logs reviews:

  • Clone prod over to DEV
  • Upgrade DEV to targeted version
  • Review and Action Skip logs
  • Clone prod over to TEST
  • Upgrade TEST to targeted version
  •  Apply skip log decision update sets.
  • Perform manual testing in TEST instance for the functionality where ATF does not have coverage
  • Run Automation test framework
  •  Track issues identified using ATF, manual testing
  • Fix the issues

Tips:

  •  Include audit data and attachments in the clone

  • Use Check Now button on the upgrade Monitor screen if the upgrade did not kick in at the scheduled time.

Skip log reviews

During the upgrade process, if the system identifies a conflict, i.e the upgrade has an update to a file that has been modified by the customer,  it skips that particular file update and generates a skip log. Customers are responsible reviewing the skip logs and take appropriate actions.


  1. Reviewed and Retained
  2. Reviewed and Reverted
  3. Reviewed and Merged
  4. Reviewed
  5. Not Reviewed

Reviewed and Reverted and Reviewed and Merged will modify the underneath application file, capturing these changes to the application file for the TEST instance promotion.


Tip : 

  • Group these skip logs by priority and action the highest priority items first from the list.
  • Make sure to right scope update set is selected while applying Review and Reverted, Reviewed and Merged decisions
  • Use the comments field to capture rationale behind the decision.



















Sunday, January 19, 2020

Bulk download attachments ServiceNow


Below Script can be used to bulk download attachments from ServiceNow.

import requests
import os
import concurrent.futures
import json

tasks =[]

def make_folder(folder):
folder = f"data/{folder}"
if not os.path.exists(folder):
os.makedirs(folder)

uri = "https://instance.service-now.com"
api = "/api/now/table/"
header = {'Content-Type': 'application/json'}


def write_to_file(file_name, r):
with open(file_name, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
os.fsync(f.fileno())

def process_attachment(obj):
attachment = obj['attachment']
attachment_sys_id = attachment['sys_id']
attachment_file_api = f"{uri}/api/now/attachment/{attachment_sys_id}/file"
binary_response = requests.get(attachment_file_api, **options)
write_to_file(f"data/{obj['number']}/{attachment['file_name']}",
binary_response)


def process_tasks(tasks):
jobs = []
with concurrent.futures.ThreadPoolExecutor(max_workers=40) as executor:
for task in tasks:
jobs.append(executor.submit(process_attachment, task))

for job in concurrent.futures.as_completed(jobs):
print(job.result())

def prepare_options():
user_name = "username"
password = "pwd"
options = {
'headers': {'Content-Type': 'application/json',
},
'auth': (user_name, password),
'timeout' : 50
}
return options
tables = ['incident']
options = prepare_options()
for table in tables:
url = f"{uri}/{api}/{table}"
response = requests.get(url, **options)
response = response.json()
response = response['result']
for record in response:
sys_id = record['sys_id']
numbr = record['number']
attachment_meta_api = f"{uri}/api/now/attachment?sysparm_query={table}
^table_sys_id={sys_id}"
a_response = requests.get(attachment_meta_api, **options)
a_response = a_response.json()
attachments = a_response['result']
if len(attachments):
make_folder(record['number'])

for attachment in attachments:
obj = {
'attachment': attachment,
'number': numbr,
'options': options
}
tasks.append(obj)

process_tasks(tasks)






The above python 3 script downloads attachments into local machine  stores them into data folder.

Inputs:


  1.  Tables  = List of task related tables that you want to download attachments from.
  2.  URI =  Instance URI
  3. userName = userName to access the instance.
  4. password = pwd to access the instance
Ensure provided user has read access to the task table. 







GRC Scripted Control Indicators

Control indicators provides a way to monitor control objective /risk Statement automatically and collects the relevant data for auditing purposes.


Control indicators can be Manual, Basic, Scripted.

Manual, Basic indicators are fairly straight forward and scripted ones tare the ones hat I am going to go through in this article.


Why and when scripted indicators required ?


Scripted indicators provides a way read the data from any part of within the platform or through integrations outside of the platform and interpret the data to derive to a conclusion whether an Item is still effective.


Objectives available for scripting :


result:   After the data collection and data interpretation once we determine the outcome and supporting data for the outcome we will have to set this values to the result variable

For example:
result.passed = true;
result.value = 500;     
result.supportingDataIds = [id1, id2, ...]     

Notes:

  1. result.passed expects either the pass or fail at the end. you must set one of this value
  2. result.value, this is for the auditing purpose,  A Value that can help you understand end result
  3. result.supportingDataIds , Array of record sys_ids from the table that has been selected in the Supporting Data table.

current:  The item that being monitored (Conrol Objective/Risk Statement) from the control indicator definition is available for access as current object








Example:

Below example  indicator is defined to run weekly to verify f incidents created last week have meaningful description for a particular business service.

The current object is used to fetch information of the the profile/entity the control objective is associated with.

Once we have the entity from the current, navigating there on to a business service that the profile is defined on to.

Once we have the business service, applying that in the encoded query to fetch incidents related business service created with in last 7 days and verifying if all those incidents have meaning description.



var count = 0;

var profile = current.profile || {};
var applies_to = profile.applies_to;
var supportingDataIds = [];

var query = 'sys_created_onRELATIVEGE@dayofweek@ago@7';
//created relative 7 days ago
query = query + '^business_service=' + applies_to;
var table = 'incident';
var inc = new GlideRecord(table);
inc.addEncodedQuery(query);

while (inc.next()) {
if (((inc.short_description + '').toString().length < 10) ||
((inc.description + '').toString().length < 20)) {
count++;
supportingDataIds.push(inc.sys_id + '');
}
}
if (count > 2) { //Mark failed id more than 2 incident records found
result.passed = false;
result.value = count;
result.supportingDataIds = supportingDataIds;
} else {
result.passed = true;
result.value = count;
}

The variable i.e count is used to track the number of incidents that did not meet the criteria , and at the end it is being used to set the result variable.

Tuesday, September 3, 2019

Script Actions in ServiceNow

Script Actions :

  • Events can be fired from most of the server side script elements for processing later. i.e Async processing.
  • Script actions can be defined with the processing logic to process those events.
  • Events are processed when the processing capability available. 
  • Events are processed as user system
  • Events may be processed in parallel if there is enough processing capacity.   i.e Schedule workers and semaphores.
  • Events are defined on a table and script actions are defined on events.












Events can be triggered using, 

gs.eventQueue('procssed.load.event',gr, parmValue1,parmValue2);

Objects available in a script action: 

current  :  represents GlideRecord object of the record on which event is triggered

event : represents event parameter object.  two additional parameters can be processed to an event when it is being triggered and those parameters are accessed using event.parm1, event.parm2 in the script actions. 


Quick points: 


  1.  Event and script actions can be used to develop event driven async integrations.
  2.  Event and script actions can be used to defer the bulk crud operations processing to later point in time.
  3.  Avoid writing lengthy script action scripts, call script includes instead.








Business Rules in ServiceNow

Business Rules :

  • Business rules are the server side processing objects.  
  • Can be configured to trigger on create/read/update/delete operations into a table.
  • Can be configured to execute before/after/async of any of the the above operations.
  • Before rules are generally used for data enrichment, validation.
  • After rules are generally used to configure notifications, perform upsert operations into a related table.
  • Async rules are generally used for outbound integrations, heavy processing logic which could  otherwise impact user experience. 
  • Display rules can be configured to pass on values from server side to client side scripts to eliminate the round trips.
  • Query rules can be configured to add additional default conditions to all the query statements performed on a table.




Objects : 

current  :  represents the current state of the record that is being processed.   Available in before, after, query, display, async business rules.

previous : represents the previous state of the record that is being processed. Available in before, after business rules.

g_scratchpad :   represents an object which can be loaded with key value pairs from server side to access at client side. Available in display business rules.

Avoid :

  •  current.update()  in before business rules. Could lead to infinite loop of rule execution without  proper conditions. 
  •  outbound integration calls in before/after business rules.  This impacts user experience.
  •  writing lengthy scripts in advanced business rules . Use script includes instead.
  •  Avoid global business rules. Use script includes where possible. 
  • Avoid circular updates among related tables.  i.e Business rules on table A updating table B, and Business rules on table B, updating table A.

Stuck with ? :


Unique key violation detected by database :   Could be because of current.update() in before business rules, or circular updates.

Workflow execution order :  Workflows run before the insertion into table and after before business rules with order <= 1000.  so, adjust the order if needed.

Empty journal fields :  values of journal fields such as work_notes, comments are not available in an after business rules, use current.work_notes.getJournalEntry(1) instead. 

Activities being duplicated : Could be because of current.update() in before business rules, or circular updates between related tables.


Here are the related articles on ServiceNow






Monday, September 2, 2019

IT job market in Melbourne

IT Jobs in Melbourne, Australia: 


Either you are an experience professional recently migrated to Melbourne or student pursuing higher studies in Melbourne in the information technology, you will find this article useful if you are actively looking for a job or planning to look for a job in the near future. After having worked more than couple of years in Melbourne as an IT professional I am sharing my thoughts.

Job portals :

The best place to start is try and understand the demand for you field of expertise are the job portals. Australia best job portal Seek so do your research such as how many job openings you could see in a week or month.  


Meetups :


  Networking is everything,  start attending meetups.  Always look for an opportunity to present a session, Presenter gets the most attention,  Also you will get an opportunity to describe your current situation while introducing yourself.   



Volunteering :

If you are falling short of expectations in terms of local experience, consider working as a Volunteer. You will get to understand work culture as well as you could use references from this work place.  If you hit a jackpot you might a job from the same work place if they are impressed with your work.


Here is the portal where could apply volunteering jobs : Volunteer Jobs






Code repositories , certifications, technical blogs :

It always helps to have additional interest in the field that are you are working, Consider contributing to open source repositories or getting certifications in the technology that you are interested in.






  All the very best !!


Here are the related articles  Jobs

Most Common Interview Questions:  Interview Questions

Sunday, September 1, 2019

The secrets of investing

The secrets of investing:

    This is one of the common question most people ask. Are there any secrets in investing ?  what are the mantras that successful investors must know, well in this article I will share my experiences and thoughts. 

Respect the money:





     Without compromising your lifestyle you could save money, you will have to choose your spending wisely. Buying luxuries such as expensive cars, jewelry, costly clothes on credit cards or loan eventually is going to create problems financially later.  Instead use that money to generate assets such as shares, real estate so you could buy those luxuries with your money down the line.

Once you have enough money to invest,  it is time to find the right investment so that money can work for you.  Opportunity is everything. 

Don't invest money alone:


         More often than not, most people invest their money because they have seen someone investing and they do not want to fall behind. Just alone buying a property or shares in a company is not investing. It is gambling !!. You could loose or win and as with any gambling the odds of loosing is more.   

    "Invest time and money.  More time and less money"


Sam,  John both earn $3,000 a month from 9-5 job, saves approximately $500 a month after  expenses. 

Sam left all his savings in the same bank account without any research and with the assumption that it is small savings anyway.  On the hand, John spent an hour in finding a bank with high interest rates and at the end of it, he found a bank that is offering 1% higher interest rate and he opened an account in that bank and started using for his savings. At the end of the six months, 

Sam with his current bank interest rate 4% 

Investment amount = 6*500 = $3000
Interest earned = $35


John with his current savings bank interest rate 5% 

Investment amount = 6*500 = $3000
Interest earned = $43.87

So, John has paid himself $13.87 for his 1 hour research over period of 6 months.  This may not be big amount but guess what it's real money and it is only over 6 months period with a savings of $500 a month. This will have compound affects on his wealth over a time period. 


Another example with capital risk which is where research is more important to minimize the odds in investing.


Sam,  John both earn $3,000 a month from 9-5 job, saves approximately $500 a month after  expenses. 

Sam started investing his savings into share market at the end of the each month, he invested in companies that are doing well in the current market conditions. He did not take into account market cycles and company fundamentals. 


John also wanted to invest in share market at the end of each month but he could not find the right companies to invest in every month so only he ended up investing 3 times $500 each for the 6 months period. At the end of 6 months, 

Sam, out of his 6 investments 

4 companies contributed to profits of 10% of each = $200
2 companies contributed to loss of 10% of each = -$100 

So, Sam's total profits  = $100


John, out of his 3 investments 

3 companies contributed to profits of 10% of each = $150, and he has potentially earned interest on the remaining money on his higher savings interest rate account.


So, John's total profits  = $150+

Your research and time has double benefits they will not only help you make profits but at times helps you limit losses.   


Here is another article that I wrote about Investing : Investing Strategies












ITIL V4 foundation exam pattern

What is the purpose of ITIL V4 foundation? The purpose of ITIL V4 foundation is to introduce readers to the management of modern IT-enable...