Scott Seixas Senior Engineering Manager ServiceNow Joe Davis Platform Architect Service Now Under the Hood Questions Agenda What is application scoping and how does it work? Developer toolkit API tips References Development Challenges
"Scott Seixas Senior Engineering Manager ServiceNow" is the property of its rightful owner. Permission is granted to
download and print the materials on this website for personal, non-commercial use only, and to display it
on your personal computer provided you do not modify the materials and that you retain all copyright
notices contained in the materials. By downloading content from our website, you accept the terms of this
agreement.
Presentation Transcript
01
Scott Seixas
Senior Engineering Manager
ServiceNow Joe Davis
Platform Architect
Service Now Under the Hood<br>
02
Questions Agenda What is application scoping and how does it work? Developer toolkit API tips References<br>
03
Development Challenges Application suite is extensively logically cross-linked
Dependent on scheme, business rule, scripts elements in other applications
Virtually impossible to modify or install app A without risking impact to app B
Difficult to iterate fast on small apps for fear of breaking core ITSM functionality
Lack of support for building and managing apps
No upgrades, versioning, dependencies
No packaging mechanism
No boundary between development and deployment<br>
04
Our solution: Application Scoping Applications are assigned a unique identifier (aka scope)
The scope is used during development to uniquely name all artifacts
Tables
Properties
User roles
The scope is used to encapsulate your runtime code
Protects your private APIs
Manages your public APIs
The scope allows you to uninstall and easily upgrade your application<br>
05
Namespacing “ There are only two hard problems in Computer Science: cache invalidation and naming things.”
- Phil Karlton The application scope is used to namespace all artifacts
All names are universally unique (tables, roles, properties, events)
Ensures conflict free installs and upgrade<br>
06
Contextual Development Ensures all new files are assigned to your current application
Application field is defaulted to the current application
Prevents you from editing files in other applications
Record is read-only with warning message to indicate it belongs to another application<br>
07
Make a Public API Some code is private to an application
Private artifacts aren’t accessible from other applications
Only expose a subset of code for public consumption
Easier to upgrade/maintain<br>
08
Make a Table Private Some tables are only used internally by an application
Don’t automatically expose tables directly to all applications and web services
Enforce APIs to access your application’s data
Use a Script Include to expose a public API<br>
09
Install / Demo Data Any record in the system can be included in your application
Provide any default configuration data
Provide optional demo data<br>
10
Application File Protection Certain files should be read-only
Better flexibility when building next version of your application
Seamless upgrades since your changes will always be applied
Protected script includes are read-only and encrypted at rest
Can’t access the raw textual content<br>
11
Table Extensions Build a lightweight application that 3rd party applications will depend on
Make your table Extensible so it can be inherited
Make your table Allow Configuration to allow new Fields, Actions, and Scripts
Build a custom application file type (Configuration Data)
Track record changes in update sets and in the application
Extend from Application File<br>
12
Dependencies Declared dependencies ensure your application will work when installed
Dependencies are tracked automatically during application development
Dependencies can reference a plugin or other scoped application<br>
13
Uninstall Reinforces confidence to install 3rd party applications since they can be removed
Use the Uninstall action on the application detail page
Provides option to keep your application data (deactivate the app)<br>
14
New Logging API: gs.debug, gs.info, gs.warn, gs.error Per application logging verbosity and destination
Properties
Session UI Debugging
Enable session debug for your application to view your logged messages
Include appropriate info, warn, error messages so user can troubleshoot
Format strings: gs.info(“Hello, {0} {1}”, firstName, lastName);
All logged messages from scope applications are stored in the App Log table<br>
15
New Extensibility API: GlideScopedEvaluator Upgrade/Maintainability
Custom implementations often changes script includes, business rules, ui actions, etc.
Those files can no longer be upgraded since they were customized
The change in approach is to operate against data (external scripts), which is unaffected by upgrades
Build extension points into your scripts
Lookup a record which contains a script
Execute the script with any arguments, receive return value<br>
16
Example Extensibility API: GlideScopedEvaluator var gr = new GlideRecord("x_acme_test_script");
gr.addQuery("name", "HelloUserScript");
gr.query();
gr.next();
var vars = {}'
vars.userName = "Demo";
var evaluator = new GlideScopedEvaluator();
evaluator.evaluateScript(gr, "script", vars);<br>
17
API Tips Use info, warn, debug, error instead of gs.log
Use RestMessageV2 and SoapMessageV2 instead of GlideHTTPRequest
Use JSON encode/decode instead of JSUtil
Use gs.nil() instead JSUtil.nil() or just follow the JavaScript truthy pattern
Use getDecryptedValue API on the Password2 field instead of GlideEncrypter
Instead of native eval use GlideScopeEvaluator
CSS Cache Buster via gs.getCSSCacheVersionString()<br>
18
References Scoped System API
http://wiki.servicenow.com/index.php?title=Scoped_System_API
Tables that are read-only from script
https://demonightlyfuji.service-now.com/sys_db_object_list.do?sysparm_query=sys_scope%3Dglobal%5Eread_access%3Dtrue%5Ecreate_access%3Dfalse%5Edelete_access%3Dfalse%5Eupdate_access%3Dfalse
Script includes that are public
https://demonightlyfuji.service-now.com/sys_script_include_list.do?sysparm_query=sys_scope%3Dglobal%5Eaccess%3Dpublic
Tables you can add new Fields
https://demonightlyfuji.service-now.com/sys_db_object_list.do?sysparm_query=sys_scope%3Dglobal%5Ealter_access%3Dtrue<br>
19
Questions<br>
20
Scott Seixas
Senior Engineering Manager
ServiceNow How Did We Do?
Your feedback on this session helps us deliver great content.
Please take a moment to complete a session survey in the Knowledge15 app or use the survey forms at the back of the room. Get Presentations
As a Knowledge15 attendee, you have exclusive access to breakout and lab session content from the event.
Go to knowledge.servicenow.com
Log into the community
Click on View Now button
knowledge.servicenow.com Thank You Joe Davis
Platform Architect
ServiceNow<br>