ServiceNow(3)

πŸ“¦
version 1.01 Β· 2 versions
, in fedora 43

🫢 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:


🍼 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