top of page

Create a form in UI Page to create incident in ServiceNow

Updated: May 8, 2023

In this blog post, we will show you how you can create a form in UI Page which can create an incident record.

  • Navigate to System Definition > UI Pages in the ServiceNow instance.

  • Click on New to create a new UI Page.

  • Give a name for the UI Page, for example, "Create Incident".

  • In the HTML field, add the following code to create a form that contains the necessary input fields and a submit button:

  <title>Create Incident</title>
  <link rel="stylesheet" href=""></link>
  <script src=""></script>
    var app = angular.module('createIncidentApp', []);
    app.controller('createIncidentCtrl', function($scope, $http) {
      $scope.createIncident = function() {
        var shortDesc = $scope.shortDesc;
        var desc = $scope.desc;
        var ci = $;

        var gr = new GlideRecord('incident');
        gr.setValue('short_description', shortDesc);
        gr.setValue('description', desc);
        gr.setValue('cmdb_ci', ci);

        alert("Incident created successfully!");

      $scope.resetForm = function() {
        $scope.shortDesc = '';
        $scope.desc = '';
        $ = '';
        $scope.ciResults = [];

      $scope.searchCi = function() {
        var query = $scope.ciQuery;
        var url = '/api/now/table/cmdb_ci?sysparm_query=' + encodeURIComponent('nameLIKE' + query + '^ORDERBYname');
        $http.get(url).then(function(response) {
          $scope.ciResults =;
<body ng-app="createIncidentApp" ng-controller="createIncidentCtrl">
  <div class="container">
    <h2>Create Incident</h2>
      <div class="form-group">
        <label for="shortDesc">Short Description:</label>
        <input type="text" class="form-control" id="shortDesc" ng-model="shortDesc"></input>
      <div class="form-group">
        <label for="desc">Description:</label>
        <textarea class="form-control" id="desc" ng-model="desc"></textarea>
      <div class="form-group">
        <label for="ci">Configuration Item :</label>
        <input type="text" class="form-control" id="ci" ng-model="" ng-change="searchCi()">
        <ul class="list-group" ng-show="ciResults.length">
          <li class="list-group-item" ng-repeat="result in ciResults" ng-click="ci = result">{{}}</li>
      <button type="button" class="btn btn-primary" ng-click="createIncident()">Create Incident</button>
      <button type="button" class="btn btn-default" ng-click="resetForm()">Reset</button>

  • Save the UI Page configuration.

You have created a UI Page that allows users to create incidents with Short Description, Description, and CI fields.

When the "Submit" button is clicked, a new incident record is created in the background using GlideRecord APIs. Note that you may need to modify the code to fit your specific requirements and configurations.

139 views0 comments


Post: Blog2_Post
bottom of page