0% found this document useful (0 votes)
10 views11 pages

Script Include

Uploaded by

Web Developer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views11 pages

Script Include

Uploaded by

Web Developer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

What is Script

Include??

@ Salma
Shaik

Reusable server side


script logic that is
executed only when
explicitly called.
Script include

1. Does not have a trigger


2. Client and server callable
depends on the
configuration
3. Code inside the script
include is always server side
code
4. Script include code is
always going to be
executed on the server

@ Salma
Shaik
Why
Script Include

Modularity

Reusability

Centralization

Testability

@ Salma
Shaik
Script Include
can be called
from
@ Salma
Shaik

1. Business Rules
2. Scheduled job
3. Script Action
4. Reference Qualifier
5. UI Action
6. UI Page
7. Workflow script
8. Client Script
9. Other Script include
Types

OnDemand/
Classless

Extend an
existing class

Define new
class

@ Salma
Shaik
On Demand

Script Include that defines a single function.


The function is callable from other server-
side scripts.
It can never be used in client-side even if
client callable option is selected.
Typically used when script logic needs to be
re-used.
In this Script name and Function must be
same.

Function OnDemand()
{
Syntax //writing the code
}

@ Salma
Shaik
Define a
new class

Script Include that defines a new


class.
Can define a collection of functions.
Initialize function is automatically
called when javascript object are
created

var Classdemo = Class.create();


Classdemo.prototype = {
Syntax
initialize: function() {},
type: 'Classdemo' };

@ Salma
Shaik
Extend a script
include
Extending of class is basically inheriting
of class, means accessing the fields and
methods of another class.
Can be called from both client and
server side.
We can extend script include class in
ServiceNow as classes are extensible.

var ExtendClass = Class.create();


ExtendClass.prototype = Object.
Syntax
extendsObject(ExistingScriptInclude
, { type: 'ExtendClass' });

@ Salma
Shaik
Best Practices

Keep it
modular

Proper Clear Proper Error


naming documentation handling
Conventions

Performance
Considerations

@ Salma
Shaik
Next steps

I'd love you to try


implementing all three types
in your ServiceNow PDI.

Consider it a training
exercise! Please let me know
in the comments on how it
goes.

Give it a shot yourself first!


I'm happy to help if you get
stuck.

@ Salma
Shaik
If you like this
content and want to
learn more
ServiceNow topics.

@ Salma
Shaik

You might also like