You are on page 1of 39

Using Perl with ServiceNow

PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Sun, 16 Mar 2014 17:13:11 PST

ServiceNow.pm

ServiceNow.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

ServiceNow module
ServiceNow Perl API - ServiceNow perl module

Desciption
ServiceNow module is a collection of Perl subroutines that provides convenient and direct access to the ServiceNow platform

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL File::Basename MIME::Types MIME::Type MIME::Base64

ServiceNow.pm

Examples
Creating an Incident
#!/usr/bin/perl -w

use ServiceNow; use ServiceNow::Configuration;

my $CONFIG = ServiceNow::Configuration->new();

$CONFIG->setSoapEndPoint("https://demoi1.service-now.com/"); $CONFIG->setUserName("admin"); $CONFIG->setUserPassword("admin");

my $SN = ServiceNow->new($CONFIG);

my $number = $SN->createIncident({"short_description" => "this incident was created from the Perl API", "category" => "hardware"});

print $number ."\n";

Querying an Incident #!/usr/bin/perl -w use ServiceNow; use ServiceNow::Configuration; my $CONFIG = ServiceNow::Configuration->new(); $CONFIG->setSoapEndPoint("https://demoi1.service-now.com/"); $CONFIG->setUserName("admin"); $CONFIG->setUserPassword("admin"); my $SN = ServiceNow->new($CONFIG); my @incidents = $SN->queryIncident({'number' => 'INC00002'}); my $count = scalar(@incidents); print "number of incidents=" . $count . "\n"; foreach my $incident (@incidents) { print "Incident number: $incident->{'number'}\n"; print "Assignent Group: $incident->{'assignment_group'}\n"; print "Opened by: $incident->{'opened_by'}\n"; print "Opened by DV: $incident->{'dv_opened_by'}\n"; print "SD: $incident->{'short_description'}\n"; print "TW: $incident->{'time_worked'}\n"; print "\n" }

ServiceNow.pm Querying Journal fields #!/usr/bin/perl -w use ServiceNow; use ServiceNow::Configuration; my $CONFIG = ServiceNow::Configuration->new(); $CONFIG->setSoapEndPoint("https://demoi1.service-now.com/"); $CONFIG->setUserName("admin"); $CONFIG->setUserPassword("admin"); my $SN = ServiceNow->new($CONFIG); my @journals = $SN->queryJournal('INC00002'); print $journals[0]->{'element'} . " = " . $journals[0]->{'value'} ."\n"; print $journals[1]->{'element'} . " = " . $journals[1]->{'value'} ."\n";

Constructor
new new(Configuration object, optional Instance ID) Example: $config = ServiceNow::Configuration->new(); $SN = ServiceNow->new($config); Sets up an instance of the ServiceNow object using a Configuration object and an optional Instance ID.

Subroutines
Incident
createIncident createIncident(optional paramaters) Example:
$number = $SN->createIncident({"short_description" => "this is the short description"});

Create an incident. Returns an incident number upon success. On failure returns undef. queryIncident queryIncident(Reference to named parameters hash of Incident fields and exact values) Example: @results = $SN->queryIncident({'number' => 'INC0000054'}); Query for Incidents matching specified criteria. Returns an array of incident records.

ServiceNow.pm updateIncident updateIncident($number, optional hash of Incident fields and values to update) Example: $ret = $SN->updateIncident($number,{$field => $value}); Update a ServiceNow incident Returns undef on failure, all other values indicate success. closeIncident closeIncident(incident number, optional hash of Incident fields and values to update) Example: $number = $SN->closeIncident($number, {$field => $value}); Close a ServiceNow Incident and optionally update field values. Returns the incident number on success, undef on failure. reopenIncident reopenIncident(incident number) Example: my $ret = $SN->reopenIncident('INC99999'); Reopen a closed ServiceNow incident. Returns the incident number on success, undef on failure. reassignIncident reassignIncident(Incident number, assignment group, optional assigned to) Example: my $ret = $SN->reassignIncident('INC99999', 'SOME_GROUP'); my $ret = $SN->reassignIncident('INC99999', 'SOME_GROUP', 'username'); Reassign a ServiceNow Incident to a new assignment_group.(and optionally specify an assigned_to) Returns the incident number on success, undef on failure.

Ticket
createTicket createTicket(Reference to named parameters hash of ticket fields and values) Example: my $number = $SN->createTicket({"category" => "hardware"}); Create a ServiceNow ticket associated with an incident. Returns a ticket number upon success. On failure returns undef. updateTicket updateTicket(The ticket number , Reference to named parameters hash of ticket fields and values to update) Example: my $ret = $SN->updateTicket($number, {$field => $value});

ServiceNow.pm Returns undef on failure, all other values indicate success. queryTicket queryTicket( Reference to named parameters hash of Incident fields and exact values ) Example: my @tickets = $SN->queryTicket({'number' => $number}); Query for tickets matching specified criteria. Reference to array of hashes of all matching tickets, undef on failure or if no records found. closeTicket closeTicket(Ticket number, {$field => $value}) Example: my $ret = $SN->closeTicket($number); my $ret = $SN->closeTicket($number, {"comments" => "ticket closed"}); Close a ServiceNow ticket and optionally specify work effort. Returns the ticket number on success, undef on failure. reopenTicket reopenTicket(The ticket number) Example: my $ret = $SN->reopenTicket('TKT99999'); Reopen a closed ServiceNow ticket. Returns the ticket number on success, undef on failure. reassignTicket reassignTicket(ticket number, the incident assignment group, optional person to assign the ticket to) Example: my $ret = $SN->reassignTicket('TKT99999', 'SOME_GROUP'); my $ret = $SN->reassignTicket('TKT99999', 'SOME_GROUP', 'username'); Reassign a ServiceNow ticket to a new assignment_group. Returns the ticket number on success, undef on failure.

RequestedItem / Request
createRequestedItem createRequestedItem(catalog item number, requested for, variables) Example:
my $req = $SN->createRequestedItem('CITM10000', "username", {'description' => 'Some description', 'group' => 'SOME_GROUP'});

Create a Service Catalog RequestedItem (and indirectly the associated Request and Tasks). Returns a RequestedItem number upon success. On failure returns undef.

ServiceNow.pm queryRequestedItem queryRequestedItem(Reference to named parameters hash of RequestedItem fields and exact values) Example: my $requestedItems = $SN->queryRequestedItem({'number' => 'SOME_RI_NUMBER'}); Query for RequestedItems matching specified criteria. Reference to array of hashes of all matching RequestedItem, undef on failure or if no records found. queryRequest queryRequest(Reference to named parameters hash of Request fields and exact values) Example: my $requests = $SN->queryRequest({'number' => 'SOME_REQUEST_NUMBER'}); Query for Requests matching specified criteria. Reference to array of hashes of all matching Request, undef on failure or if no records found.

Task
createTask createTask(optional paramaters) Example:
$number = $SN->createTask({"short_description" => "this is the short description"});

Create a task record. Returns an task number upon success. On failure returns undef. closeTask closeTask(task number, optional work effort in seconds) Example: my $ret = $SN->closeTask($number); my $ret = $SN->closeTask($number, {$field => $value}); Close a ServiceNow Task and optionally update field values. Returns true on success, undef on failure. reopenTask reopenTask(task number) Example: my $ret = $SN->reopenTask('TASK99999'); Reopen a closed ServiceNow Task. Returns true on success, undef on failure. reassignTask reassignTask(task number, assignment group, optional person it is being assigned to) Example: my $ret = $SN->reassignTask('TASK99999', 'SOME_GROUP'); my $ret = $SN->reassignTask('TASK99999', 'SOME_GROUP', 'username');

ServiceNow.pm Reassign a ServiceNow Task to a new assignment_group. (and optionally specify an assigned_to) Returns true on success, undef on failure. updateTask updateTask(task number, reference to named parameters hash of Task fields and values) Example: my $ret = $SN->updateTask($number, {$field => $value}); Update a ServiceNow Task. Returns true on success, undef on failure. queryTask queryTask(reference to named parameters hash of Task fields and exact values ) Example: my @tasks = $SN->queryTask({'number' => $number}); foreach my $task (@tasks) { print "Incident number: $task->{'number'}\n"; print "Assignent Group: $task->{'assignment_group'}\n"; print "Opened by: $task->{'opened_by'}\n"; print "SD: $task->{'short_description'}\n"; print "TW: $task->{'time_worked'}\n"; print "\n" } Query for Tasks matching specified criteria. Array of hashes of all matching Tasks, undef on failure or if no records found.

Journal
queryJournal queryJournal(Incident/Ticket/Task number, optional journal field name ) Query for journals entries for the specified incident, ticket or task. Return array of hashes of all matching Journals, undef on failure or if no records found. There will be one hash per per journal entry, 'value' will contain the journal entry string, 'element' will be the name of the field (e.g. 'comments', 'work_notes', etc.) appendJournal appendJournal(Incident/Ticket/Task number, field name, journal text) Example: my $ret = $SN->appendJournal('INC99999', 'comments' "some comment text");

Append a journal entry to the specified journal field of an incident, ticket, or task. Returns true on success, undef on failure.

ServiceNow.pm

Approval
queryApproval queryApproval(reference to named parameters hash of approval fields and exact values) Example: my @approvals = $SN->queryApproval({'approver' => 'username'}); Query for approvals Return array of hashes of all matching approvals, undef on failure or if no records found. approve approve(sys_id of the approval,approval state,optional comment text) Example: my $ret = $SN->approve($sys_id, 'Approved'); my $ret = $SN->approve($sys_id, 'Rejected', "Please do something else"); Approve/reject a ServiceNow approval request and optionally provide a comment. Returns the sys_id on success, undef on failure.

Dictionary
queryFields queryFields(table, optional boolean) Example: my @fields = $SN->queryFields('incident'); List all the fields of an Incident, Request, RequestedItem or Task. Returns a reference to a hash of fields in the specified table type. The hash key is the field name, and the hash value is a hash reference to attributes about the field: 'mandatory', 'hint', 'label', 'reference' and 'choice'. Returns undef on failure. If getchoices is true then 'choices' is a reference to a hash containing individual choices, keyed by choice value and containing choice 'label' and 'hint'.

ITIL Objects
Incident.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Incident module
ServiceNow Perl API - Incident perl module

Desciption
An object representation of an Incident in the ServiceNow platform. Provides subroutines for querying, updating, and creating incidents.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Incident.pm

10

Examples
Creating an Incident
#!/usr/bin/perl -w

use ServiceNow; use ServiceNow::Configuration; use ServiceNow::ITIL::Incident;

my $CONFIG = ServiceNow::Configuration->new();

$CONFIG->setSoapEndPoint("https://demoi1.service-now.com/"); $CONFIG->setUserName("admin"); $CONFIG->setUserPassword("admin");

# setting incident values as a hash map in the insert argument my $incident = ServiceNow::ITIL::Incident->new($CONFIG); my $sys_id = $incident->insert({"short_description" => "this incident was created from the Perl API", "category" => "hardware"}); print $sys_id ."\n";

# setting incident values by making setValue calls to the incident object $incident = ServiceNow::ITIL::Incident->new($CONFIG); $incident->setValue("short_description", "this incident was created from the Perl API - 2"); $incident->setValue("category", "hardware"); $sys_id = $incident->insert(); print $sys_id ."\n";

Querying for Incidents


#!/usr/bin/perl -w

use ServiceNow; use ServiceNow::Configuration; use ServiceNow::ITIL::Incident;

my $CONFIG = ServiceNow::Configuration->new();

$CONFIG->setSoapEndPoint("https://demoi1.service-now.com/"); $CONFIG->setUserName("admin"); $CONFIG->setUserPassword("admin");

my $incident = ServiceNow::ITIL::Incident->new($CONFIG); $incident->addQuery("assignment_group", "Service Desk"); $incident->addQuery("category", "Hardware"); $incident->query(); while($incident->next()) { print "number=" . $incident->getValue("number") . "\n"; print "sd=" . $incident->getValue("short_description") . "\n";

Incident.pm
print "opened_by Display Value= " . $incident->getDisplayValue("opened_by") . "\n"; print "opened_by sys_id= " . $incident->getValue('opened_by'); }

11

Adding an attachment to a newly created Incident #!/usr/bin/perl -w use ServiceNow; use ServiceNow::Configuration; use ServiceNow::ITIL::Incident; my $CONFIG = ServiceNow::Configuration->new(); $CONFIG->setSoapEndPoint("https://demoi1.service-now.com/"); $CONFIG->setUserName("admin"); $CONFIG->setUserPassword("admin");

my $incident = ServiceNow::ITIL::Incident->new($CONFIG); $incident->setValue("short_description", "test incident for attachment 2"); $incident->insert(); $incident->attach("/Users/davidloo/Desktop/test_files/number_test.xls");

Constructor
new
new(Configuration); Example: $incident = ServiceNow::ITIL::Incident->new($CONFIG); Takes a configuration object and manufactures an Incident object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Incident.pm

12

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

Subroutines
close
close(number, hashmap); Example: $incident->close($number) Close an incident and update values described in the hash map passed in.

reopen
reopen(number, hashmap); Example: $incident->reopen($number); Re-open a closed incident and update values described in the hash map passed in.

createProblem
createProblem(); Create a problem ticket from an incident and associate it. Returns the sys_id of the newly created problem ticket

createChange
createChange(); Create a change request from an incident and associate it. Returns the sys_id of the newly created change request

Problem.pm

13

Problem.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Problem module
ServiceNow Perl API - Problem perl module

Desciption
An object representation of a Problem in the ServiceNow platform. Provides subroutines for querying, updating, and creating problems.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Problem.pm

14

Constructor
new
new(Configuration); Example: $problem = ServiceNow::ITIL::Problem->new($CONFIG); Takes a configuration object and manufactures a Problem object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

Change.pm

15

Change.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Change module
ServiceNow Perl API - Change perl module

Desciption
An object representation of an Change in the ServiceNow platform. Provides subroutines for querying, updating, and creating change requests.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Change.pm

16

Constructor
new
new(Configuration); Example: $change = ServiceNow::ITIL::Change->new($CONFIG); Takes a configuration object and manufactures an Change object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

Request.pm

17

Request.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Request module
ServiceNow Perl API - Request perl module

Desciption
An object representation of an Request in the ServiceNow platform. Provides subroutines for querying, updating, and creating service catalog requests.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Request.pm

18

Constructor
new
new(Configuration); Example: $request = ServiceNow::ITIL::Request->new($CONFIG); Takes a configuration object and manufactures an Request object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

Subroutines
createRequest
createRequest(user); Create a service request for the specified user

RequestedItem.pm

19

RequestedItem.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

RequestedItem module
ServiceNow Perl API - RequestedItem perl module

Desciption
An object representation of an Requested Item in the ServiceNow platform. Provides subroutines for querying, updating, and creating service catalog requested item.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

RequestedItem.pm

20

Constructor
new
new(Configuration); Example: $req_item = ServiceNow::ITIL::RequestedItem->new($CONFIG); Takes a configuration object and manufactures an Requested Item object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

SC_Task.pm

21

SC_Task.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

SC_Task module
ServiceNow Perl API - SC_Task perl module

Desciption
An object representation of an Service Request Task in the ServiceNow platform. Provides subroutines for querying, updating, and creating sc_task.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

SC_Task.pm

22

Constructor
new
new(Configuration); Example: $sc_task = ServiceNow::ITIL::RequestedItem->new($CONFIG); Takes a configuration object and manufactures an Service Catalog Task object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

Ticket.pm

23

Ticket.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Ticket module
ServiceNow Perl API - Ticket perl module

Desciption
An object representation of a Ticket in the ServiceNow platform. Provides subroutines for querying, updating, and creating tickets.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Ticket.pm

24

Constructor
new
new(Configuration); Example: $ticket = ServiceNow::ITIL::Ticket->new($CONFIG); Takes a configuration object and manufactures an Ticket object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

Task.pm

25

Task.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Task module
ServiceNow Perl API - Task perl module

Desciption
An object representation of a Task in the ServiceNow platform. Provides subroutines for querying, updating, and creating tasks. Task is the parent class of Incident, Problem, Change, SC_Task and Ticket. These child classes inherit subroutines from this class.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Task.pm

26

Constructor
new
new(Configuration); Example: $task = ServiceNow::ITIL::Task->new($CONFIG); Takes a configuration object and manufactures an Task object connected to the ServiceNow instance

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert

query update

Subroutines
create
create(optional paramaters) Example: $task->create(); Creates and inserts Task/Incident/Ticket/SC_Task record into the respective table. Returns the number of created record on succes, undef on failure.

close
close(number of record, optional parameters) Example: $task->close('INC1000312'); Sets the state of Task/Incident/Ticket/SC_Task to closed and updates the respective table. Returns the number of created record on success, undef on failure.

Task.pm

27

reopen
reopen(number of record, optional parameters) Example: $task->reopen('TKT1003010'); Sets the state of Task/Incident/Ticket/SC_Task to open and updates the respective table.

reassign
reassign(number, group, user); Example: $incident->reassign($number, 'Database', 'user') Re-assign an incident to the group and user specified.

queryJournal
queryJournal(configuration file, optional field name) Example: $task->queryJournal($config, 'work_notes'); Returns an array of hash references to each journal associated with the current Task/Incident/Ticket/SC_Task. Optional field name refines the search to a specified field.

attach
attach(file path) Example: $task->attach("/Users/davidloo/Desktop/test_files/number_test.xls"); Attach a file to a record of Task

Approval.pm

28

Approval.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Approval module
ServiceNow Perl API - Approval perl module

Desciption
An object representation of an Approval record in the ServiceNow platform. Provides subroutines for querying, updating, and creating approvals.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Approval.pm

29

Constructor
new
new(Configuration); Example: $approvals = ServiceNow::ITIL::Approval->new($CONFIG); Takes a configuration object and manufactures an Approval object connected to the ServiceNow instance

Subroutines inherited from Task.pm


attach close create queryJournal reassign reopen

Subroutines inherited from GlideRecord.pm


addQuery getValue getDisplayValue setValue next insert query update

Subroutines
reject
reject(sys_id of approval record, optional comment string) Example: $approval->reject($sysID,$comment); Reject the Approval record with specified sys id, and add comment to approval if given.

approve
approve(sys_id of approval record, optional comment string) Example: $approval->approve($sysID,$comment); Approve the Approval record with specified sys id, and add comment to approval if given.

30

Other
Configuration.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Configuration module
ServiceNow Perl API - Ticket perl module

Desciption
An object representation of a Configuration object used to access your ServiceNow instance.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

Configuration.pm

31

Constructor
new
new(); Example: $conf = ServiceNow::Configuration->new(); Create a new Configuration object and start customizing it to be used for other objects

Subroutines
getSoapEndpoint
getSoapEndpoint(target_table); Gets the complete SOAP endpoint used to access your ServiceNow instance, given the table name.

setSoapEndPoint
setSoapEndPoint(endpoint_url); Sets the complete SOAP endpoint used to access your ServiceNow instance. For example: my $CONFIG = ServiceNow::Configuration->new(); $CONFIG->setSoapEndPoint("https://instance_name.service-now.com/"); my $incident = ServiceNow::ITIL::Incident->new($CONFIG);

getUserName
getUserName(); Get the user name used to authenticate a connection to the SOAP endpoint

setUserName
setUserName(user_name); Set the user name used to authenticate a connection to the SOAP endpoint

getUserPassword
getUserPassword(); Get the user password used to authenticate a connection to the SOAP endpoint

Configuration.pm

32

setUserPassword
setUserPassword(user_password); Set the user password used to authenticate a connection to the SOAP endpoint

getConnection
getConnection(target_table); Get the Connection object used to access the ServiceNow SOAP endpoint

GlideRecord.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

GlideRecord module
ServiceNow Perl API - GlideRecord perl module

Desciption
An object representation of a GlideRecord object used to access your ServiceNow instance.

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL

GlideRecord.pm

33

Constructor
new
new(Configuration object, Table name, optional caller object) $config = ServiceNow::Configuration->new(); $glideRecord = ServiceNow::GlideRecord->new($config,'incident',$me); Constructor. Access to the ServiceNow Glide Record object. The caller object is optional unless creating a Class that inherits GlideRecord (See any class in ServiceNow/ITIL for example).

Subroutines
insert
insert(optional hash argument) Example: $glideRecord->insert(); Inserts glide record into Table. Returns sys id.

setValue
setValue(name, value) Example: $glideRecord->setValue('caller_id','56'); Sets element within Glide Record with name to specified value. Will not effect the GlideRecord within the Table until inserted or updated.

addQuery
addQuery(name, value) Example: $glideRecord->addQuery('number','INC1000014'); $glideRecord->query(); Refines query to include only the Glide Records with field name=value.

GlideRecord.pm

34

query
query(optional hash arguments) Example: $glideRecord->query(); Returns all Glide Records in the Table with specified query. Step through the Records with the next() call.

next
next() Example: if($glideRecord->next()); while($glideRecord->next()); Steps through the results of Glide Record query. Returns TRUE if more elements exist.

update
update(optional hash arguments) Example: $glideRecord->setValue('name','value'); $glideRecord->update(); Updates Glide Record in table with the Glide Record object. Changes to Glide Record object will not take effect until updated or inserted. Returns sys_id of record on success, undef of failure.

getValue
getValue(name) Example: $glideRecord->getValue($name); Get value of element name in GlideRecord. Returns string value of element.

getDisplayValue
getDisplayValue(name) Example: $glideRecord->getDisplayValue($name); Gets display value of element name in GlideRecord. A display value would be the string name, instead of the sys_id in the case of a reference field, or the string value instead of the number value in the case of choice fields.

Attachment.pm

35

Attachment.pm
Perl API ServiceNow.pm ITIL Objects Incident.pm Problem.pm Change.pm Request.pm RequestedItem.pm SC_Task.pm Ticket.pm Task.pm Approval.pm Other Configuration.pm GlideRecord.pm Attachment.pm Related Topics Integration Overview Web Services Get the Book Get the Book

Attachment module
ServiceNow Perl API - Attachment perl module

Desciption
An object representation of an Attachment in the ServiceNow platform. Provides subroutines for creating an attachment and attaching to an existing record

System Requirements
The ServiceNow Perl API requires Perl 5.8 with the following modules installed SOAP::Lite (prerequisites http://soaplite.com/prereqs.html) 0.71 or later Crypt::SSLeay IO::Socket::SSL File::Basename MIME::Types MIME::Type MIME::Base64

Attachment.pm

36

Constructor
new
new(Configuration); Example: $task = ServiceNow::Attachment->new($CONFIG); Takes a configuration object and manufactures an Task object connected to the ServiceNow instance

Subroutines
create
create(path, table_name, sys_id) Example:
$attachment->create("/Users/davidloo/Desktop/test_files/number_test.xls", "incident", "9d385017c611228701d22104cc95c371");

Creates an attachment from a file on the local disk, to an existing record defined by table_name and sys_id Returns the sys_id of the ecc_queue record, undef if failed

Article Sources and Contributors

37

Article Sources and Contributors


ServiceNow.pm Source: http://wiki.servicenow.com/index.php?oldid=80844 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko Incident.pm Source: http://wiki.servicenow.com/index.php?oldid=80839 Contributors: David Loo, Joseph.messerschmidt, Kenny.caldwell, Neola, Rachel.sienko Problem.pm Source: http://wiki.servicenow.com/index.php?oldid=80840 Contributors: David Loo, Joseph.messerschmidt, Neola, Rachel.sienko Change.pm Source: http://wiki.servicenow.com/index.php?oldid=80835 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko Request.pm Source: http://wiki.servicenow.com/index.php?oldid=80841 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko RequestedItem.pm Source: http://wiki.servicenow.com/index.php?oldid=80842 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko SC_Task.pm Source: http://wiki.servicenow.com/index.php?oldid=80843 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko Ticket.pm Source: http://wiki.servicenow.com/index.php?oldid=80846 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko Task.pm Source: http://wiki.servicenow.com/index.php?oldid=80845 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko Approval.pm Source: http://wiki.servicenow.com/index.php?oldid=80833 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko Configuration.pm Source: http://wiki.servicenow.com/index.php?oldid=183464 Contributors: David Loo, Jason.petty, Joseph.messerschmidt, Rachel.sienko GlideRecord.pm Source: http://wiki.servicenow.com/index.php?oldid=82161 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko Attachment.pm Source: http://wiki.servicenow.com/index.php?oldid=80834 Contributors: David Loo, Joseph.messerschmidt, Rachel.sienko

Image Sources, Licenses and Contributors

38

Image Sources, Licenses and Contributors


Image:Knowledge.gif Source: http://wiki.servicenow.com/index.php?title=File:Knowledge.gif License: unknown Contributors: G.yedwab

You might also like