Shravan Vishwanathan
Shravan Vishwanathan

Reputation: 113

Extract incident details from Service Now in Excel

I am trying to extract ticket details from Service Now. Is there a way to extract the details without ODBC ? I have also tried the solution mentioned in [1]: https://community.servicenow.com/docs/DOC-3844, but I am receiving an error 9 -subscript out of range.

Is there a better way to extract details efficiently? I tried asking this in the service now forum but I thought I might get other opinions from here.

Upvotes: 0

Views: 6236

Answers (1)

Anil_M
Anil_M

Reputation: 11453

It's been a while since this question is asked. Hopefully following is still useful.

I am extracting change data (not incident) , but the process still should be same. You will need to gather incident table and column information. Then there are couple of ways to approach the problem.

1) If the data you are extracting has fixed parameters , such as fixed period or fixed column or group etc., then you can create a report within servicenow and then use REST/SOAP API to get the data in text/csv format. You can use different python modules to convert from csv to xls or xlsx depending on you need. I used openpyXL ,csv , xlsreader ,xlswriter etc.

See here for a example ServiceNow - How to use SOAP to download reports

2) If the data has dynmaic parameters where you need to change columns, dates or filter etc, you can still use soap / REST API but form query within python scripts instead of having static report. This way you can change it based on your requirement on the fly.

Here is an example query for DB. you can use example for above. Just switch url with following.

table_name = 'u_change_table_name' #SN DB holding change/INCIDENT info

table_limit = 800

table_query = 'active=true&sysparm_display_value=true&planned_start_date=today'

date_query = 'chg_start_date>=javascript:gs.daysAgoStart(1)^active=true^chg_type=normal'

table_fields = 'chg_number,chg_start_date,chg_duration,chg_end_date'  #Actual column names from DB and not from SN report.

url= (
      'https://yourcompany.service-now.com/api/now/table/' +table_name +\
       '?sysparm_query=' + date_query + '&sysparm_fields=' \
       + table_fields  + '&sysparm_limit=' +  str(table_limit)
     )

Upvotes: 1

Related Questions