Using ServiceNow PERL API to access cmdb_ci_outage table

icalderus
Kilo Contributor

Hello All!

Second post here, thanks in advance for the help.

I had previously written the forums asking for help with querying the cmdb_ci_outage table , piping those results to a flat file. I was able to do so successfully using the ServiceNow ODBC on windows xp. However, things have changed.

The scope of the project is now such that Windows is being tossed out altogether, and I have been asked to use the Service Now Perl API to accomplish the same thing, that is , access the cmdb_ci_outage table and pipe the output into a flat file.

As such I must say I am completely new to the Perl API. From what I gather there are some functions that can get incident info, enter incident info, etc. However my need is to specifically query the cmdb_ci_outage table using the Perl API.

Does ANYONE have any ideas or sample clues/code that may help? I must add I havent touched Perl in quite some time, however I am fairly decent with ksh code so I gather I can suffice.

thanks guys!

17 REPLIES 17

There are three methods:
One: configure a named view in ServiceNow which contains only the fields you're interested in, then reference the view in your SOAP call. Add this line after your "my @params = (SOAP..." line:



push(@params, SOAP::Data->name('__use_view' => 'myviewname')); # Replace myviewname with the name of your view


Two: exclude the fields from the response by specifying which fields you don't want to see:


push(@params, SOAP::Data->name('__exclude_columns' => 'comma,separated,list,of,fields')) # Example 'active,state,description'


Three: Ignore the fields in your perl code when parsing the hash of record fields. This is dependent on your specific implementation.


icalderus
Kilo Contributor

i like option one. if i am correct, the view would be defined within the web user interface, is that correct? or, is this view something we can create on the backend?


thanks!


You are correct.

See: http://wiki.servicenow.com/index.php?title=View_Management

Make sure you use the "name" of the view and not the "title" in your SOAP request. Look up the name on the sys_ui_view.list in your instance to get the actual name instead of the title displayed on the view picker on the form.


icalderus
Kilo Contributor

ok i think the way to create the aforementioned view would be

Navigate to System Definition > Database Views.
Click New to create a new view.

And then so forth..

is this correct? i am a little new to Service Now UI and couldnt locate database views using the navigation.


No, database views won't do what you need for this. You can create these views using the Personalize Form Layout menu option. That screen will allow you to choose "New..." under the Form View and Section heading. This is the view you'll need to reference.