- Mastering ServiceNow(Second Edition)
- Martin Wood
- 862字
- 2021-07-08 10:36:36
Developing applications in Studio
In the previous chapter, we started building the Hotel application. This included defining the data storage needed by building tables, exploring the dictionary, and creating relationships. All these items are in different menus, meaning you need to keep navigating to different places, without a consistent overview.
ServiceNow Studio is designed to help with this. It provides a single location where all the configuration for the app is collected together. This lets you jump among the things you are working on without the clutter of configuration from other areas. Here's how to use it:
- Open up Studio by navigating to System Applications > Studio, click on the Go button under Open Studio, and then click on Hotel in the Load Applications dialog.
- Studio collects all the configuration together, making it easy to find existing artifacts and create new ones. The Application Explorer sidebar contains a categorized list of Application Files, while the Go To and Code Search capabilities lets you jump right to what you want.
- Using Application Explorer, click on Check-In Table under Tables in Data Model.
You should see a familiar interface-the same Table form we used in Chapter 1, ServiceNow Foundations-to add fields to.
- The Go-To search bar is really useful for quickly switching to other artifacts. Click on the Go-To link in the top right, or use the Control + Shift + O (Cmd + Shift + O on Mac) keyboard shortcut, and search for
Check-In
. Several relevant options are available, essentially filtering the items available in Application Explorer. For now, click on the Form option.Notice how Form Designer has opened in a new tab, keeping the Table form accessible with a single click.
- Click File, then Settings to open up the Application Settings form. This gives many options that control how the application works. Several will be discussed later in this chapter, others as we work through the book. For now, let's make our lives easier by associating the Hotel menu (that appears in the left menu) with our application. It sets the default whenever we create a table. Set the following field, then save.
- Menu:
Hotel
- Menu:
- Another fantastic feature of Studio is Code Search. While we will be investigating scripting in the next two chapters, it would be remiss to not point this out. Click on the link in the top right, or press Control + Shift + F (Cmd + Shift + F on Mac) to bring up the dialog. Search for
TableUtils
and select the Search in all applications checkbox to see how it can scan over 20 scripting tables in one go. I can't tell you how much time this saves!
Ensure you try out all the features of Studio. Letting you easily and quickly find and switch between all the items you are creating will really help you accelerate your application development.
Recording files
Application Explorer shows all the application files associated with the application. Every time you make any configuration, an entry is made in the Application Files [sys_metadata
] table. This associates the table, form, e-mail notification, or script that you made with your application. But which application is that? Let's find out:
- If you are using ServiceNow Studio, the configuration you make is always associated with the application you opened Studio against (this is listed in the top right of the Studio interface).
- In the standard interface, the application you are editing is the one you selected in System Settings. This can be changed by clicking on the cog icon next to your name, going to Developer, and then choosing it from the Application Menus selector. (It's much easier if you enable the Show application picker in header option.)
Tip
Consider the application file's application as metadata that provides the instance with information about the configuration.
Follow these steps:
- To see what Application Files are created, click on the blue Create New Application File button in the Studio interface. The dialog that appears does a much better job of organizing the platform-configuration options into logical categories than the standard application navigator, providing help text and great filtering. Notice how there are almost 80 options-and that doesn't even cover them all! Close the dialog when done.
- Normally, you don't need to worry about the application files and the data they store. The instance looks after it. However, let's open one up to see how it works. The Application File for a configuration artifact is always accessible through the menu of the record. Open up the Check-In table record (use the Application Explorer or Go To search, or just click on the tab if it's open), and then choose Show File Properties from the Additional Actions menu.
Several interesting options are available in the application file. The related lists at the bottom show any related items (the fields in the Check-In table are listed, for example), while Versions stores the changes that the record has gone through.
Tip
Versioning is incredibly useful for scripts. It can show you, using a line-by-line difference view, how your code has evolved over time. Chapter 10, Packaging with Applications, Update Sets, and Upgrades dives into this-and the Protection policy field-in more detail.