Thursday, November 3, 2016

How to Upload a file using Macro in Service Now?

This blog explains about how to implement 'Upload File' feature using Macro in Service Catalog in Service Now

Use case - Provide the ability to upload a file in Service Catalog Item

Solution

- UI Macros
- Create New, Add the Jelly script code as shown below


<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<b>Use the paperclip</b>  
<a onclick="saveCatAttachment(gel('sysparm_item_guid').value, 'sc_cart_item')">  
<img title="Attachments..." height="16" src="images/icons/attachment.gifx" border="0" width="16"/></a>  
<b>to attach items to this request.</b>  
</j:jelly>

-  Go to Service Catalog Item, where you want to implement this feature
- Create a new variable of a type 'Macro with Label'
- Goto 'Type Specifications' tab and Choose the Macro newly created in above step
- This how it shows



Wednesday, November 2, 2016

How to see all the changes performed by specific user in Service Now ?

This blog explains about how to see, what are all the activities performed in any Service Now Instance by specific user ?

Use Case : I wanted to see what are all the activities performed by 'Ravi' in 'Development Service Now Instance' ?

Solution

- System Logs -> Transactions
- You can filter by user name




Wednesday, October 26, 2016

How to retrieve Specific User associated Manager, Director , Title, Department related information in Service Now?


Scenario : Get a specific user associated attributes such as Manager, Job title, Department, etc..

Solution


- Create a Catalog Client script
- 'Applies to ' 'Variable Set'
- Select the appropriate variable set name
- Select the apprpriate variable name
- Use below script


function onChange(control, oldValue, newValue, isLoading) {
var userValue1 = g_form.getReference('variables.cat_requested_for');
// Get Manager
var managerVar = userValue1.manager;

// Get Job title
var managerVar = userValue1.title;

// Get Department
var managerVar = userValue1.department;

}

Tuesday, October 25, 2016

How to make 'Service Catalog Shopping Cart Window' scroll-able in Service Now

This blog explains about how can we make 'Service Catalog Shopping Cart Window' Scrollable in Service Now

Scenario: Let's say, My Catalog Item has 500 variables when I scroll down to bottom of the page, I wanted to have 'Shopping cart window' also should be scrollable along with scroll bar

Solution:

- Create the following Catalog client script


function onLoad() {
   //Type appropriate comment here, and begin script below
   
 !function(t){t.fn.jScroll=function(n){function o(t){this.min=t.offset().top,this.originalMargin=parseInt(t.css("margin-top"),10)||0,this.getMargin=function(n){var o=t.parent().height()-t.outerHeight(),r=this.originalMargin;return n.scrollTop()>=this.min&&(r=r+i.top+n.scrollTop()-this.min),r>o&&(r=o),{marginTop:r+"px"}}}var i=t.extend({},t.fn.jScroll.defaults,n);return this.each(function(){var n=t(this),r=window;t("div.cms_layout_container",window.parent.document).length>0&&(r=window.parent);var e=t(r);t("div.touch_scroll").length>0&&(e=t("div.touch_scroll"));var s=new o(n);e.scroll(function(){n.stop().animate(s.getMargin(e),i.speed)})})},t.fn.jScroll.defaults={speed:"slow",top:10}}(jQuery),$j("#sc_cart_contents").jScroll({top:20,speed:1500});
}


How can we align or split variables in a Catalog Item ?

This blog explains about how to arrange variables in a Service Catalog Item ?

Scenario : Let's say, there are 500 variables in a Catalog Item, Out of box, all these variables displayed in single column, If you want to arrange these variables in three columns

Solution

- Create 'Container Start' , 'Contanier Split' , 'Container End' variables wherever required in 'Variables' section in a given Catalog


How to Reduce a Catalog Item Variable width in Service Now ?

This blog explains about how can we manage the height/ width of any variable defined in Servie Catalog Items

- Look for 'Catalog client Script'  , Click on New
- Select the appropriate value for 'Applies to' , If it is 'Variable Set' or 'Catalog Item'
- Follow the below script



Wednesday, September 21, 2016

How to Use Client Script in Service Now ?



Client scripts are shipped to the client (the browser) and run there instead of on the server. Users who know JavaScript can define scripts to run in the client browser. Several types of scripts are supported

Requirement : Whenever any drop down list value changed, Populate the selected value of Drop down list value into another field

Eg : Whenever 'Device type' value modified, display the selected 'Device type' value in 'Name' field



Solution 
Create a client script as shown below screenshot

     var deviceType = g_form.getValue('device_type');
     var deviceTypeLabel=g_form.getOption('device_type',deviceType).text;
     g_form.setValue('name',deviceTypeLabel);




For More Info , Refer http://wiki.servicenow.com/index.php?title=Client_Scripts#gsc.tab=0