Friday, June 19, 2015

Challenges in Service Now


This blog explains most of the challenges faced so far in my experience

- Design a custom calendar Page, Based on custom tables and out of box tables. For eg : There is a table called 'Business Events' , users can create as many as business events with start and end date. All these business events should be appear in custom calendar page as per their scheduled time frames.By placing mouse cursor on the calendar, display specific event information by mouse hover.

- Create a JDBC data source to fetch data from one system to other system, and target should system should have live feed. That means whenever new record inserted/updated/deleted those changes should reflect in target table right away without any delay

- Write a simple background script, iterate through all the records in a table, identify what are the composite unique fields 

How to Promote a field in Service Now ?


This very common requirement in any Database to extend a table. Developers must be very careful when designing the DB tables and organizing the data. If you are already in middle of the development and encountered that there are more than one table need to share the same fields which are common in all the tables, then create a parent table and promote the commonly used fields into parent table, so that all the child tables can share the fields.


Syntax : 

GlideDBUtil.promoteColumn('table_to_move_from', 'table_to_move_to', 'field_to_move', true);


Example : Let's say I want to move 'category' field from 'incident' table to 'task' table
 GlideDBUtil.promoteColumn('incident', 'task', 'category', true);


Reference : http://www.servicenowguru.com/scripting/promote-field-extended-table-servicenow/

Wednesday, June 3, 2015

How to Create a Module based on URL


This blog explains about how do you create a Module based on URL :

Scenario : For example, I want to create a new module called 'Search' , By clicking on this I want to display one of the UI page created in Service Now.


- Launch Service Now Instance

- Edit the application where you want to create new module, ( Right click on Application -> Edit Application Menu)

- Create new module

- Choose 'Link Type' as 'URL Arguments'

- Provide the URL in 'Arguments'

- Save, Refresh, click on newly created Module, you should see the page.


Hint : If you want to see the URL for any specific Incident record, Open the incident in a new tab, copy the URL and paste it into Arguments.



Tuesday, May 26, 2015

How to mark fields as Mandatory on any form in Service Now ?


This blog explains about how to mark specific fields as mandatory on any form in service now ?

Scenario : I want to mark 'First Name' field as mandatory on a form, that means without entering the value for 'First Name' field and user tries to submit the form, should display required validation message

Steps to accomplish


- We can achieve this by writing UI Policies on a form.

- Launch the form where you want to to write the UI Policies

- Right click on form banner menu -> Personalize -> All -> Click on 'UI Policies' tab -> Click on New

- If it is 'Eureka' version, click on 'Default' link

- Choose the table name

- Click on 'New' on 'UI Policy Actions' section as highlighted below.

- Select the field name, and set 'true' to mandatory column.

- Save , launch the form, you will notice '*' symbol for mandatory fields.





How to invoke a client script by clicking on 'Submit' or onChange actions



This blog explains about how to invoke a Client script by clicking on 'Submit' button.

Scenario : For example, there are two date fields on the form, by clicking on 'Submit' button, validate date 1 must be before date 2. Perform this validation by clicking on 'Submit' button.

- Launch the form where you want to write the client script

- Right click on 'Form Header' -> Personalize -> All

- click on 'client Scripts' section

- Click on 'New'

- Below is how client script looks like




-  If you want to write invoke client script whenever any field value changes, for Eg : Whenever user enter a value for 'Date' field on a form.



















Wednesday, May 20, 2015

How to create a record into a custom table using business rule in service now?


This blog explains about how to create a business rule to create a record into custom table.

Scenario : Whenever new incident created, Newly created Incident Number and description should stored into a custom table called 'incident_backup' table


- Create a new table called 'incident_backup' with 'description' and 'number' fields.

- Launch 'Create New' Incident module

- Right click on 'Create New' incident form header -> Configure -> Business Rule

- Create a new business rule

- Give a valid name to the business rule

- When to run ? Choose 'Insert'

- Select 'Advance' check box

- Write a function as below

createIncidentBackupRecord();  // Invoking a function
// Function definition as follows below

function createIncidentBackupRecord(){
try{
// Create a glide record for the 'incident-backup' table
var gr = new GlideRecord("incident_backup");
gr.initialize();
// Set event start, event end, name

gr.short_description=current.short_description;
gr.number=current.number;

gr.insert();

}catch(Exception){
gs.log(" Create Incident Backup Record Exception Occured while creating Blackout Window"+Exception);

}
}

- Save the Business Rule

- Create a new incident record, as soon as new incident row get created, this will trigger above business rule, and this business rule will create a new record into 'incident_backup' table



How to Create a Module based on URL ?


This blog explains about how to create a Module using arguments or How to test only Catalog item ?

Scenario : Create a catalog item,  User don't need to 'Maintain items' Module every time to test the catalog item.

Steps

- Go to Maintain Items under Service Catalog

-  Search for the catalog item, for which you want to create a module, Press Ctl + Mouse click on the Name of the catalog item, That will launch the item in a new tab

- For example, below is how the URL looks like, once you open the catalog item in a new window

https://fmdev.service-now.com/sc_cat_item.do?sys_id=3ec4fde02bcc06001f1847f119da15cc&sysparm_view=item&sysparm_record_target=sc_cat_item&sysparm_record_row=1&sysparm_record_rows=175&sysparm_record_list=type%21%3Dbundle%5Esys_class_name%21%3Dsc_cat_item_guide%5Etype%21%3Dpackage%5Esys_class_name%21%3Dsc_cat_item_content%5Esc_catalogs%3DNULL%5EORsc_catalogsDOES+NOT+CONTAIN0b22fd2ad7021100b9a5c7400e610319%5EORDERBYDESCsys_updated_on

- Copy only the URL excluding https://xxxxx.service-now.com as shown above highlighted. URL should looks like below

sc_cat_item.do?sys_id=3ec4fde02bcc06001f1847f119da15cc&sysparm_view=item&sysparm_record_target=sc_cat_item&sysparm_record_row=1&sysparm_record_rows=175&sysparm_record_list=type%21%3Dbundle%5Esys_class_name%21%3Dsc_cat_item_guide%5Etype%21%3Dpackage%5Esys_class_name%21%3Dsc_cat_item_content%5Esc_catalogs%3DNULL%5EORsc_catalogsDOES+NOT+CONTAIN0b22fd2ad7021100b9a5c7400e610319%5EORDERBYDESCsys_updated_on


- Now Right click on the application where you want to create a new module

- Create New Module 

- Choose 'Link Type' as 'URL(from Arguments.)

- Provide a proper name to the Module

- Paste the above copied URL into 'Arguments' field.

- Refresh the URL and search for the Application, you will see a new module created in above step, If you click on you will see a catalog item, Enter the details and click on 'Try it'