ServiceNow(3)
π«Ά ServiceNow module π«Ά
okay bestie, welcome to ServiceNow(3) β it's a User Contributed Perl Documentation page, and honestly? it's giving the Service-now Perl API. This is the ServiceNow perl module, and she exists so your Perl can talk directly to the Service-now platform. no cap. β¨
πΈ Desciption πΈ
(i'm keeping the spelling bestie, it's iconic π )
The ServiceNow module is a collection of Perl subroutines that provides convenient and direct access to the Service-now platform. that's the whole vibe: you write Perl, it handles the Service-now side. π¦
π System Requirements π
The Service-now Perl API needs Perl 5.8, plus these modules installed:
SOAP::Lite(prerequisites http://soaplite.com/prereqs.html) β 0.71 or later, no earlierCrypt::SSLeayIO::Socket::SSL
πΌ Constructor πΌ
new
new(Configuration object, optional Instance ID)
example, because we love a demo:
$config = ServiceNow::Configuration->new();
$SN = ServiceNow->new($config);
this sets up an instance of the ServiceNow object using a Configuration object and an optional Instance ID. it's the lil "hi bestie, let's go" moment. π«Ά
π Subroutines π
π₯ Incident π₯
createIncident
createIncident(optional paramaters)
example:
$number = $SN->createIncident({"short_description" => "this is the short description"});
creates an incident. gives you an incident number back when it works, and undef when it doesn't. π
queryIncident
queryIncident(Reference to named parameters hash of Incident fields and exact values)
example:
@results = $SN->queryIncident({'number' => 'INC0000054'});
queries for Incidents that match your criteria. you get back an array of incident records. π
updateIncident
updateIncident($number, optional hash of Incident fields and values to update)
example:
$ret = $SN->updateIncident($number,{$field => $value});
updates a ServiceNow incident. undef on failure, and every other value means success β so basically "not undef = we ate". π₯
closeIncident
closeIncident(incident number, optional hash of Incident fields and values to update)
example:
$number = $SN->closeIncident($number, {$field => $value});
closes a ServiceNow Incident, and you can optionally specify work effort. returns the incident number on success, undef on failure. π
reopenIncident
reopenIncident(incident number)
example:
my $ret = $SN->reopenIncident('INC99999');
reopens a closed ServiceNow incident. returns the incident number on success, undef on failure. the comeback era. π¦
reassignIncident
reassignIncident(Incident number, assignment group, optional assigned to)
examples:
my $ret = $SN->reassignIncident('INC99999', 'SOME_GROUP');
my $ret = $SN->reassignIncident('INC99999', 'SOME_GROUP', 'username');
reassigns a ServiceNow Incident to a new assignment_group, and optionally you can 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"});
creates a ServiceNow ticket associated with an incident. returns a ticket number upon success, undef on failure. π
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});
undef on failure, and every other value means success. β¨
queryTicket
queryTicket( Reference to named parameters hash of Incident fields and exact values )
example:
my @tickets = $SN->queryTicket({'number' => $number});
queries for tickets matching your criteria. you get a reference to an array of hashes of all matching tickets β or undef on failure, or if literally no records were found. π
closeTicket
closeTicket(Ticket number, {$field => $value})
examples:
my $ret = $SN->closeTicket($number);
my $ret = $SN->closeTicket($number, {"comments" => "ticket closed"});
closes a ServiceNow ticket, and you can optionally specify work effort. returns the ticket number on success, undef on failure. π
reopenTicket
reopenTicket(The ticket number)
example:
my $ret = $SN->reopenTicket('TKT99999');
reopens a closed ServiceNow ticket. returns the ticket number on success, undef on failure. main character energy fr. π
reassignTicket
reassignTicket(ticket number, the incident assignment group, optional person to assign the ticket to)
examples:
my $ret = $SN->reassignTicket('TKT99999', 'SOME_GROUP');
my $ret = $SN->reassignTicket('TKT99999', 'SOME_GROUP', 'username');
reassigns 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'});
creates a Service Catalog RequestedItem β and indirectly the associated Request and Tasks too, the way one thing just spawns a whole little family. returns a RequestedItem number upon success, undef on failure. π
queryRequestedItem
queryRequestedItem(Reference to named parameters hash of RequestedItem fields and exact values)
example:
my $requestedItems = $SN->queryRequestedItem({'number' => 'SOME_RI_NUMBER'});
queries for RequestedItems matching your criteria. gives you a reference to an array of hashes of all matching RequestedItem, or undef on failure or if no records were found. πΈ
queryRequest
queryRequest(Reference to named parameters hash of Request fields and exact values)
example:
my $requests = $SN->queryRequest({'number' => 'SOME_REQUEST_NUMBER'});
queries for Requests matching your criteria. reference to an array of hashes of all matching Request, undef on failure or if no records were found. β
π Task π
createTask
createTask(optional paramaters)
example:
$number = $SN->createTask({"short_description" => "this is the short description"});
creates a task record. returns an task number upon success, undef on failure. (yes bestie, "an task", i don't make the rules, i just respect the original π
)
closeTask
closeTask(task number, optional work effort in seconds)
examples:
my $ret = $SN->closeTask($number);
my $ret = $SN->closeTask($number, $seconds);
closes a ServiceNow Task, and you can optionally specify work effort. returns true on success, undef on failure. β
reopenTask
reopenTask(task number)
example:
my $ret = $SN->reopenTask('TASK99999');
reopens a closed ServiceNow Task. returns true on success, undef on failure. π₯
reassignTask
reassignTask(task number, assignment group, optional person it is being assigned to)
examples:
my $ret = $SN->reassignTask('TASK99999', 'SOME_GROUP');
my $ret = $SN->reassignTask('TASK99999', 'SOME_GROUP', 'username');
reassigns a ServiceNow Task to a new assignment_group (and optionally you can 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});
updates 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"
}
queries for Tasks matching your criteria. you get an array of hashes of all matching Tasks, undef on failure or if no records were found. π
πΈ Journal πΈ
queryJournal
queryJournal(Incident/Ticket/Task number, optional journal field name )
queries for journal entries for the specified incident, ticket or task. returns an array of hashes of all matching Journals, undef on failure or if no records were found. there's one hash per per journal entry, 'value' holds the journal entry string, and 'element' is the name of the field (like 'comments', 'work_notes', etc.). π
appendJournal
appendJournal(Incident/Ticket/Task number, field name, journal text)
example:
my $ret = $SN->appendJournal('INC99999', 'comments' "some comment text");
appends a journal entry to the specified journal field of an incident, ticket, or task. returns true on success, undef on failure. π
β Approval β
queryApproval
queryApproval(reference to named parameters hash of approval fields and exact values)
example:
my @approvals = $SN->queryApproval({'approver' => 'username'});
queries for approvals. returns an array of hashes of all matching approvals, undef on failure or if no records were found. π
approve
approve(sys_id of the approval,approval state,optional comment text)
examples:
my $ret = $SN->approve($sys_id, 'Approved');
my $ret = $SN->approve($sys_id, 'Rejected', "Please do something else");
approves/rejects a ServiceNow approval request, and you can optionally drop a comment. returns the sys_id on success, undef on failure. π
π§ Dictionary π§
queryFields
queryFields(table, optional boolean)
example:
my @fields = $SN->queryFields('incident');
lists 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'. π¦
and that's the whole page bestie, we ate and left no crumbs π this lil tour came to you from perl v5.42.0, dated 2025-07-25, and yes the page itself is ServiceNow(3) β go forth and make Service-now do your bidding. periodt. β¨ππ
π¦ where this page comes from
- fedora 43: perl-ServiceNow-API 1.01-38.fc43 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms