The ability to build a custom application in ServiceNow makes ServiceNow such a versatile product. As ServiceNow was first released to the market as a service desk solution, developers have explored the potential of the platform, and since then it has been used in various areas of the business.
However, there are still many ways of using ServiceNow that are not included with the baseline system, and for this, we can create a custom application.
Before creating a custom application, it is worth considering whether a custom application will provide the best solution. Sometimes, we can use an existing ServiceNow application to perform the functionality we want to achieve, using it directly or slightly modifying it for our needs. If this is the case, then it is worth considering not creating a custom application and using the platform instead.
If the functionality you need would take a large modification to an existing application or simply does not exist at that point, it is advisable to create a custom application.
Once we create a new application, we can then start adding application files to that application. The application files we create become part of the application.
To create a new application, we can navigate to System Applications | Applications, and we will be shown the current applications that have been created on this instance. We then need to click on the New button on the far right, as shown in Figure 12.1:
Figure 12.1: Instance applications page
Once the New button has been selected, you are given a series of choices about where you would like to start from when creating your application.
We can see the options given in Figure 12.2:
Figure 12.2: Application creation options
From this set of choices, we can decide from what starting point we want to create our application. The top two choices are the most commonly used generally. Starting from scratch is exactly that, only the application is created and the new application scope. No tables or modules or access controls are made for you.
Creating a custom application guides you through creating a table, modules, and access controls. After that, it is much the same as starting from scratch.
The third option, to start from a service, is rarely used in my experience, but allows a developer to enhance a service created from the service creator and potentially overwrite it when complete.
The final option here is not available as part of the baseline system, but can be used if service management is activated. This option again is not as well used, although it allows creation from an existing process.
When selecting start from a template, we are presented with a further page, which we can see in Figure 12.3:
Figure 12.3: Application creation template option choices
From here, we can either create from a predefined template, or configure settings further to create the application.
Now the custom application has been created, we can start to add application files and build up the application.
Once the application has been created, we can start to build up the application with application files. These are the files that, when put together, make up the application. When the application is created, an application scope is also created for the application. On the creation of the application, you will also be put into the new application scope, so it is important to be aware of this.
You will also see that your update set has changed once you create a new update set to a new default update set for the application scope you are now in. As you are in the application scope of your new application, any customizations made will be added to your new application.
To keep track of the current scope and update set, it can be useful to show the application and update set picker when developing. These two options can be set in the Developer tab of the system settings, which can be seen in the following figure:
Figure 12.4: Developer system settings showing the application and update set picker
By setting the two picker options in Figure 12.4, we are then shown the current application scope and update set at the top of the screen in the header bar. These are shown in a drop-down field, so both can easily be changed if required.
We can see here both of the picker drop-down fields that are displayed in the header bar:
Figure 12.5: Application and update set picker
These picker fields are especially helpful if you are working between update sets or in multiple scopes for your current development.
When working in multiple tabs, it can be a wise idea to refresh your browser page to ensure that the pickers are up-to-date on the tab you are working on.
Now that we have created and started to build our application, we can move on to the development of our application.
In this chapter, we will also build an example custom application to reinforce the theory that we learn. For our example, we will build an application to hold data for users' access.
First, we need to create the application. From the options we saw in Figure 12.2, we are going to select Create custom application. Once we have selected this, we are given the form shown in Figure 12.6:
Figure 12.6: Create custom application form
In this form, we need to give our application a name, which will then fill in the rest of the fields. We can change the values in the fields, but in the Scope field, the prefix will have to be the prefix for your company or developer instance.
For our example, we also want to create a table, so we...