Blog

Status Report Application

If you haven't created a new application in ServiceNow before, you may be surprised how easy the process is.

In this example, I'll create a Status Report application from scratch. You can use the Status Report application to report on Projects or your daily work.

Even if you don't need a Status Report application, it is a good example of the application creation process.


Screenshots

Status Report List (Click to Expand Picture)

Status Report Form (Click to Expand Picture)


Step 1: Create the Application and Table

1. Click the New Application button and fill in details needed for the new application.

New Application Form

2. Create the Status Report Table

Create Status Report Table

3. Add Fields to Status Report Table

  • Column Label: Project, Type: Reference, Table: Project, Reference Qual: active=true
  • Column Label: Report Start, Type: Date
  • Column Label: Report End, Type: Date
  • Column Label: Scope Status, Type: Choice
  • Column Label: Schedule Status, Type:  Choice
  • Column Label: Resource Status, Type:  Choice
  • Column Label: Cost Status, Choice

4. Turn on Auditing

a. Open Status Report Form
b. Right Click Header Bar > Personalize > Dictionary
c. Select the "Collection" dictionary entry
d. Audit: true
e. Click Save


Step 2: Personalize Form and Lists

1. Customize Status Report Form

Status Report Form

a. Open Status Report Form
b. Right Click Header Bar > Personalize > Form Layout

  • Number
  • Project
  • Project.Project Manager
  • Assigned to
  • |- split-|
  • Report start
  • Report end
  • |- end split -|
  • Project.Name
  • Work Notes
  • Activities (filtered)

c. Click Save
d. Right Click Header Bar > Personalize > Form Layout
e. Form Section: new > Status
f. Add Columns

  • Scope status
  • Schedule status
  • |- split-|
  • Resource status
  • Cost status

g. Click Save

Note: You can also add other columns from Project like Planned start date and Planned end date to the form as well.

2. Personalize List

Status Report List

a. Open Status Report List
b. Right Click Header Bar > Personalize > List Layout

  • Number
  • User
  • Report start
  • Report end
  • Project
  • Project.Short Description

3. New Label For Project Short Description Field

a. Open Status Report Form
b. Right Click Project Short Description field  > Personalize > Label

  • Table: pm_project
  • Label: Project name
  • Plural: Project name

c. Right Click Header Bar and click Insert

4. New Label for Assigned To Field

a. Open Status Report Form
b. Right Click Assigned to field  > Personalize > Label

  • Table: u_status_report
  • Label: User
  • Plural: Users

c. Right Click Header Bar and click Insert

5. Default User to logged-on user

a. Open Status Report Form
b. Right Click User field  > Personalize > Dictionary
c. Dictionary Overrides > New

  • Base Table: task
  • Table: Status Report [u_status_report]
  • Column name: assigned_to
  • Override default value: true
  • Default value: javascript:gs.getUserID()

d. Click Save

6. Add Choice List Entries for Schedule Status

a. Open Status Report Form
b. Right Click Schedule Status field  > Show Choice List
c. Add Choice List entries

  • Table: u_status_report, Element: u_schedule_status, Label: According to Plan , Value: According to Plan, Seq: 0
  • Table: u_status_report, Element: u_schedule_status, Label: Caution, Value: Caution, Seq: 1
  • Table: u_status_report, Element: u_schedule_status, Label: Behind Schedule, Value: Behind Schedule, Seq: 2

7. Add Choice List Entries for Cost Status

a. Open Status Report Form
b. Right Click Cost Status field  > Show Choice List
c. Add Choice List entries

  • Table: u_status_report, Element: u_schedule_status, Label: On Budget , Value: On Budget, Seq: 0
  • Table: u_status_report, Element: u_schedule_status, Label: Caution , Value: Caution, Seq: 1
  • Table: u_status_report, Element: u_schedule_status, Label: Over Budget, Value: Over Budget, Seq: 2

d. Click Save

8. Add Choice List Entries for Scope Status

a. Open Status Report Form
b. Right Click Scope Status field  > Show Choice List
c. Add Choice List entries

  • Table: u_status_report, Element: u_schedule_status, Label: According to Plan , Value: According to Plan, Seq: 0
  • Table: u_status_report, Element: u_schedule_status, Label: Caution, Value: Caution, Seq: 1
  • Table: u_status_report, Element: u_schedule_status, Label: Changed, Value: Changed, Seq: 2

d. Click Save

9. Add Choice List Entries for Resource Status

a. Open Status Report Form
b. Right Click Resource Status field  > Show Choice List
c. Add Choice List entries

  • Table: u_status_report, Element: u_schedule_status, Label: Adequate , Value: Adequate, Seq: 0
  • Table: u_status_report, Element: u_schedule_status, Label: Over resources, Value: Over Resources, Seq: 1
  • Table: u_status_report, Element: u_schedule_status, Label: Under resources, Value: Under resources, Seq: 2
  • Table: u_status_report, Element: u_schedule_status, Label: Resource wait, Value: Resource wait, Seq: 3

d. Click Save

10. Personalize Activities

a. Open Status Report Form
b. Right Click Activities > Personalize

  • Project
  • User
  • Report start
  • Report end
  • Schedule status
  • Scope status
  • Cost status
  • Resource status
  • Opened by
  • Work notes

11. Add Related Lists

a. Add Approvers Related Lists if applicable


Step 3: Add Modules

1. Right click the Status Report Application
2. Edit Application
3. Add these Modules

  • Title | Table | Active | Filter | Order | Link type | Roles | Image
  • All | u_status_report | true |  | 100 | List of Records | itil  | images/icons/all.gif
  • Current | u_status_report | true | u_report_startONLast 7 days@javascript:gs.daysAgoStart(7)@javascript:gs.daysAgoEnd(0)^EQ | 200 | List of Records | itil  | images/icons/time.gif 
  • Past | u_status_report | true | u_report_start<javascript:gs.daysAgoStart(7)^EQ | 300 | List of Records | itil  | images/icons/roster_submitted.gif
  • Separator |  | true |  | 400 | Separator  
  • Current | u_status_report | true | u_report_startONLast 7 days@javascript:gs.daysAgoStart(7)@javascript:gs.daysAgoEnd(0)^assigned_to=javascript:gs.getUserID()^EQ | 500 | List of Records | itil  | images/icons/time.gif 
  • Past | u_status_report | true | u_report_start<javascript:gs.daysAgoStart(7)^assigned_to=javascript:gs.getUserID()^EQ | 600 | List of Records | itil  | images/icons/roster_submitted.gif

Step 4: Data Checks and Advanced Features

1. Add Data Policy

Status Report Required Fields Data Policy

a. Open Status Report Form
b. Right Click Header Bar > Personalize > Data Policies

  • Table: Status Report [u_status_report]
  • Reverse if false: true
  • Apply to import sets: true
  • Apply to SOAP: true
  • Use as UI Policy on client: true
  • Short Description: Status Report Required Fields

c. Click Save
d. Add Data Policy Rules

  • Field name: User, Mandatory: true
  • Field name: Report start, Mandatory: true
  • Field name: Report end, Mandatory: true
  • Field name: Cost status, Mandatory: true
  • Field name: Resource status, Mandatory: true
  • Field name: Schedule status, Mandatory: true
  • Field name: Scope status, Mandatory: true
  • Field name: Project, Mandatory: true

2. Duplicate Status Report Check

Business Rule: Duplicate Status Report Check

When: before
Condition: current.u_report_start.changes() || current.u_report_end.changes()
Script:

checkDuplicateName();

function checkDuplicateName() {
var grStatusReport = new GlideRecord('u_status_report');
grStatusReport.addQuery('u_report_start', current.u_report_start);
grStatusReport.addQuery('u_report_end', current.u_report_end);
grStatusReport.addQuery('u_project', current.u_project);
grStatusReport.query();
if (!grStatusReport.next()) {
return;
}
current.setAbortAction(true);
gs.addErrorMessage('Status Report on Project '+current.u_project.number+' for ' +current.u_report_start+ ' already exists.');
}

3. Add Field Styles

a. Personalize Field Styles for Status Fields

Field Styles

  • Table | Field name | Value | Style
  • u_status_report | u_cost_status | Caution | "background-color: orange;color: white;font-weight:bold;"
  • u_status_report | u_cost_status | On Budget | "background-color: green;color: white;font-weight:bold;"
  • u_status_report | u_cost_status | Over Budget | "background-color: red;color: white;font-weight:bold;"
  • u_status_report | u_resource_status | Adequate | "background-color: green;color: white;font-weight:bold;"
  • u_status_report | u_resource_status | Caution | "background-color: orange;color: white;font-weight:bold;"
  • u_status_report | u_resource_status | Over resources | "background-color: orange;color: white;font-weight:bold;"
  • u_status_report | u_resource_status | Resource wait | "background-color: orange;color: white;font-weight:bold;"
  • u_status_report | u_resource_status | Under resources | "background-color: red;color: white;font-weight:bold;"
  • u_status_report | u_schedule_status | According to Plan | "background-color: green;color: white;font-weight:bold;"
  • u_status_report | u_schedule_status | Behind Schedule | "background-color: red;color: white;font-weight:bold;"
  • u_status_report | u_schedule_status | Caution | "background-color: orange;color: white;font-weight:bold;"
  • u_status_report | u_scope_status | According to Plan | "background-color: green;color: white;font-weight:bold;"
  • u_status_report | u_scope_status | Caution | "background-color: orange;color: white;font-weight:bold;"
  • u_status_report | u_scope_status | Changed | "background-color: red;color: white;font-weight:bold;"

4. Add Field Style Client Scripts

Client Script Field Styles

Add optional field styles for the status fields

Client Script: Schedule Status Field onChange
Type: OnChange
Field Name: Schedule Status
Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 if (isLoading || newValue == '') {
return;
 }
 var csLabel = g_form.getLabel('u_status_report.u_schedule_status');
 var csValue = g_form.getValue('u_status_report.u_schedule_status');
 if (csValue == 'According to Plan') {
csLabel.style.color= 'black'; csLabel.style.fontWeight='normal';
 }
 else if (csValue == 'Caution') {
csLabel.style.color= 'orange'; csLabel.style.fontWeight='bold';
 }
 else if (csValue == 'Behind Schedule') {
csLabel.style.color= 'red'; csLabel.style.fontWeight='bold';
 }
 else { csLabel.style.color= 'black'; csLabel.style.fontWeight='normal'; } 
}

Client Script: Resource Status onChange
Type: onChange
Field Name: Resource Status
Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 if (isLoading || newValue == '') {
return;
 }
 var csLabel = g_form.getLabel('u_status_report.u_resource_status');
 var csValue = g_form.getValue('u_status_report.u_resource_status');
 if (csValue == 'Adequate') {
csLabel.style.color= 'black'; csLabel.style.fontWeight='normal';
 }
 else if (csValue == 'Over resources') {
csLabel.style.color= 'orange'; csLabel.style.fontWeight='bold';
 }
 else if (csValue == 'Under resources') {
csLabel.style.color= 'red'; csLabel.style.fontWeight='bold';
 } 
 else if (csValue == 'Resource Wait') {
csLabel.style.color= 'blue'; csLabel.style.fontWeight='bold';
 }
 else { csLabel.style.color= 'black'; csLabel.style.fontWeight='normal'; } 
}

Client Script: Scope Status onChange
Type: onChange
Field Name: Scope Status
Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 if (isLoading || newValue == '') {
return;
 }
 var csLabel = g_form.getLabel('u_status_report.u_scope_status');
 var csValue = g_form.getValue('u_status_report.u_scope_status');
 if (csValue == 'According to Plan') {
csLabel.style.color= 'black'; csLabel.style.fontWeight='normal';
 }
 else if (csValue == 'Caution') {
csLabel.style.color= 'orange'; csLabel.style.fontWeight='bold';
 }
 else if (csValue == 'Changed') {
csLabel.style.color= 'red'; csLabel.style.fontWeight='bold';
 }
 else { csLabel.style.color= 'black'; csLabel.style.fontWeight='normal'; } 
}

Client Script: Cost Status onChange
Type: onChange
Field Name: Cost Status
Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
 if (isLoading || newValue == '') {
return;
 }
 var csLabel = g_form.getLabel('u_status_report.u_cost_status');
 var csValue = g_form.getValue('u_status_report.u_cost_status');
 if (csValue == 'On Budget') {
csLabel.style.color= 'black'; csLabel.style.fontWeight='normal';
 }
 else if (csValue == 'Caution') {
csLabel.style.color= 'orange'; csLabel.style.fontWeight='bold';
 }
 else if (csValue == 'Over Budget') {
csLabel.style.color= 'red'; csLabel.style.fontWeight='bold';
 }
 else { csLabel.style.color= 'black'; csLabel.style.fontWeight='normal'; } 
}

Client Script: Status Fields onLoad
Type: onLoad
Script:

function onLoad() {
//Resource Status
var csResourceStatusLabel = g_form.getLabel('u_status_report.u_resource_status');
var csResourceStatusValue = g_form.getValue('u_status_report.u_resource_status');
if (csResourceStatusValue == 'Adequate') {
csResourceStatusLabel.style.color= 'black'; csResourceStatusLabel.style.fontWeight='normal';
}
else if (csResourceStatusValue == 'Over resources') {
csResourceStatusLabel.style.color= 'orange'; csResourceStatusLabel.style.fontWeight='bold';
}
else if (csResourceStatusValue == 'Under resources') {
csResourceStatusLabel.style.color= 'red'; csResourceStatusLabel.style.fontWeight='bold';
}
else if (csResourceStatusValue == 'Resource Wait') {
csResourceStatusLabel.style.color= 'blue'; csResourceStatusLabel.style.fontWeight='bold';
}
else { csResourceStatusLabel.style.color= 'black'; csResourceStatusLabel.style.fontWeight='normal'; }
//Scope Status
var csScopeStatusLabel = g_form.getLabel('u_status_report.u_scope_status');
var csScopeStatusValue = g_form.getValue('u_status_report.u_scope_status');
if (csScopeStatusValue == 'According to Plan') {
csScopeStatusLabel.style.color= 'black'; csScopeStatusLabel.style.fontWeight='normal';
}
else if (csScopeStatusValue == 'Caution') {
csScopeStatusLabel.style.color= 'orange'; csScopeStatusLabel.style.fontWeight='bold';
}
else if (csScopeStatusValue == 'Changed') {
csScopeStatusLabel.style.color= 'red'; csScopeStatusLabel.style.fontWeight='bold';
}
else { csScopeStatusLabel.style.color= 'black'; csScopeStatusLabel.style.fontWeight='normal'; }
//Cost Status
var csCostStatusLabel = g_form.getLabel('u_status_report.u_cost_status');
var csCostStatusValue = g_form.getValue('u_status_report.u_cost_status');
if (csCostStatusValue == 'On Budget') {
csCostStatusLabel.style.color= 'black'; csCostStatusLabel.style.fontWeight='normal';
}
else if (csCostStatusValue == 'Caution') {
csCostStatusLabel.style.color= 'orange'; csCostStatusLabel.style.fontWeight='bold';
}
else if (csCostStatusValue == 'Over Budget') {
csCostStatusLabel.style.color= 'red'; csCostStatusLabel.style.fontWeight='bold';
}
else { csCostStatusLabel.style.color= 'black'; csCostStatusLabel.style.fontWeight='normal'; }


//Schedule Status
var csScheduleStatusLabel = g_form.getLabel('u_status_report.u_schedule_status');
var csScheduleStatusValue = g_form.getValue('u_status_report.u_schedule_status');
if (csScheduleStatusValue == 'According to Plan') {
csScheduleStatusLabel.style.color= 'black'; csScheduleStatusLabel.style.fontWeight='normal';
}
else if (csScheduleStatusValue == 'Caution') {
csScheduleStatusLabel.style.color= 'orange'; csScheduleStatusLabel.style.fontWeight='bold';
}
else if (csScheduleStatusValue == 'Behind Schedule') {
csScheduleStatusLabel.style.color= 'red'; csScheduleStatusLabel.style.fontWeight='bold';
}
else { csScheduleStatusLabel.style.color= 'black'; csScheduleStatusLabel.style.fontWeight='normal'; }

}

Step 4: Create an Update Set

1. Backup Application Code

a. Click Application > Publish to Update Set

  • Application Name: Status Report
  • Version: 1.0

b. Click Publish