How-To Build a custom application step by step

Not applicable

NOTE: I need to uload and link the images for this article. It is going to take some time. bare with me.

First: None of this would have been possible without the help of the service-now team members. Thanks for pushing me in the right direction! More then once.

This is a great case study on how to create your own custom application in service-now.com from start to finish. The techniques discussed in this article are used across the board to create new applications. We are currently on our 5th custom application and have proceeded through each one just like this.

Asset Movement Management Application

Creating the new tables for the new application


First you need to create 2 new tables. Go to Tables & Columns to create the new table space. We called ours RMA because it is a replacement for our current Return Merchandise Authorization process. The second table is called Equipment Requests. Let me first explain the differences. The RMA table will be used for the movement of equipment that is already in place and needs repair or is being retired or moved from its current location. The Equipment Request application is used for the initial movement of a new piece of equipment. (i.e. We have a new piece of equipment that has been ordered and received. Now it needs to go to its new home.)

You need to go to System definition and then click the link for Tables & Columns


Place the information in the appropriate boxes at the bottom of the form.
Label = The name that will appear at the top of lists.
Table name = The actual table name. Follow the naming convention of the other tables
Extends base table = you can extend a table that has already been created sharing the characteristics it has in common with other tables or you can start a table from scratch by selecting none. We selected task as the new table would need to interact with the task table much like incident, problem, and change do.
Create new application = This is where you decide if you want a new application to appear in the navigation pain and you also decide on the name you want to give the application.
Create new module = This is where you decide where you want a new module to be located. It defaults to — The New One — Meaning it will create the new module in the new application you have specified above.

Create the new RMA table.


Label: RMA
Table name: rma
Extends base table: task
Create new application: Yes named Asset Movement Mgmt
Create new module: Yes in application — The New One —

Click Do It! YOU CAN NOT UNDO A TABLE ONCE YOU HAVE CREATED IT!!!

Hit F5 to refresh the screen.

When you create the second table you want to uncheck the "create new application" box as it will have already been created from the first table you created.

Repeat process for the second application.

Label: Equipment Request
Table name: equip_request
Extends base table: task
Create new application: NO and no name
Create new module: Yes in application Asset Movement Mgmt.

After you have created the 2 applications you should end up with something that looks like this in the navigation pain on the left.


And the applications will look like this. An almost blank slate that we will have to improve upon to reach the final result.

Rreferance:
Wiki that explains the creation of a new table.
http://wiki.service-now.com/index.php?title=How_to_create_your_own_tables

14 REPLIES 14

Not applicable

Automation of the forms CONT.


This script is used for workflow purpose. In this case the same asset that is the Affected asset is going to be fixed and shipped back out as the Replacement asset. We do not want the equipment administrator to be able to ship the asset back to its original location and then receive it afterwards. This would cause havoc on the record in CMDB so we simply do not allow it to happen.

Client Script: BCF RMA disable aff asset onchange CS5

**Script Code**


//Script created by Jeff Bloyer
//Apr 16 2007
//This script checks the Replacement Asset to the Affected asset. If the asset is the same then it removes the receive date and receive by fields. This is done because if the assets are the same then the asset should be been received before it was fixed. This is also used to disable the automation so that the asset can not be moved back into the to be repaired location after it has been shipped back as the replacement.


function onChange(control, oldValue, newValue) {

//variables that check the users roles
var isAdmin = g_user.hasRole('admin');

//variables that get control of the field then get the values
var gcAffAsset = g_form.getControl('location');
var vAffAsset = g_form.getValue('u_affected_asset');

//checks to see if values are equil and not administrator.
if (newValue == vAffAsset && isAdmin == false) {

//makes the specified field not visible to the users
g_form.setVisible('u_receive_date', false);
g_form.setVisible('u_received_by', false);

}
}



This script is used for work flow also. This script will remove all the fields on the form till the user fills in the RMA from location. Once location if filled in you are then able to select an Affected asset. This is important because if you look at the Affected asset reference field dictionary you will see that we are dependent on the RMA from location field. So making the user pick a location first is Key! This script also has a little secret. It clears the field data if the user changes the affected asset. If the user changes the affected asset the entire process needs to start over. The equipment admins are the only ones that have the access to make that change so it should not happen unless the situation is highly unusual

Client Script: BCF RMA disable all till Location CS6

**Script Code**



//Script created by Jeff Bloyer
//Apr 16 2007
// This script hides the fields that should not be filled in unless a location is filled in first so that the affected asset field knows where the asset is coming from.

function onChange(control, oldValue, newValue) {

//variables that check the users roles
var isAdmin = g_user.hasRole('admin');

//variables that get control and then retrieve the values of the fields
var gcLocation = g_form.getControl('u_rma_location');
var vLocation = g_form.getValue('u_rma_location');


if (vLocation == "" && isAdmin == false) {

//test alert used for testing purposes.
//This is disabled when not testing.
//alert ('step 1');

//removes the affected asset information and
// clears it because the location has changed
g_form.setValue('u_affected_asset', "");
g_form.setValue('u_affected_asset.location', "");
g_form.setValue('u_affected_asset.install_status', "");
g_form.setValue('u_affected_asset.location', "");
g_form.setValue('u_affected_asset.name', "");
g_form.setValue('u_affected_asset.operational_status', "");
g_form.setValue('u_affected_asset.u_in_rma_process', "");
g_form.setValue('u_need_replacement', "");

//disables the fields so that you can not set the wrong asset
g_form.setVisible('u_affected_asset', false);
g_form.setVisible('u_affected_asset.location', false);
g_form.setVisible('u_affected_asset.install_status', false);
g_form.setVisible('u_affected_asset.name', false);
g_form.setVisible('u_affected_asset.operational_status', false);
g_form.setVisible('u_need_replacement', false);

} if (vLocation != "" && vLocation == oldValue && isAdmin == false) {

//test alert used for testing purposes.
//This is disabled when not testing.
//alert ('step 2');

//re-enables the fields
g_form.setVisible('u_affected_asset', true);
g_form.setVisible('u_affected_asset.location', true);
g_form.setVisible('u_affected_asset.install_status', true);
g_form.setVisible('u_affected_asset.name', true);
g_form.setVisible('u_affected_asset.operational_status', true);
g_form.setVisible('u_need_replacement', true);

} if (vLocation != "" && vLocation != oldValue && isAdmin == false) {
//test alert used for testing purposes.
//This is disabled when not testing.
//alert ('step 3');

//removes the affected asset information and
//clears it because the location has changed
g_form.setValue('u_affected_asset', "");
g_form.setValue('u_affected_asset.location', "");
g_form.setValue('u_affected_asset.install_status', "");
g_form.setValue('u_affected_asset.location', "");
g_form.setValue('u_affected_asset.name', "");
g_form.setValue('u_affected_asset.operational_status', "");
g_form.setValue('u_affected_asset.u_in_rma_process', "");
g_form.setValue('u_need_replacement', "");

//re-enables the fields
g_form.setVisible('u_affected_asset', true);
g_form.setVisible('u_affected_asset.location', true);
g_form.setVisible('u_affected_asset.install_status', true);
g_form.setVisible('u_affected_asset.name', true);
g_form.setVisible('u_affected_asset.operational_status', true);
g_form.setVisible('u_need_replacement', true);
return;

}
}


This is yet another work flow script. This script while only used in one situation is it vitally important. This script forces the user to save the RMA before they can process a replacement if they are creating an RMA from the RMA table. If they are creating the RMA from the incident form this script is not used. The equipment admin are the only people that have the ability to issue and RMA without an incident associated to it so this script will not be used much but it sure will save some headaches.

Client Script: BCF RMA disabled rep asset onload CS7

**Script Code**


//Script created by Jeff Bloyer
//Apr 16 2007
//This script checks to see if affected asset has been filled in and if needs replacement is no. If either is true it removes the specified fields so that they can not be filled in till the proper information is filled out and saved.

function onLoad() {

//variables that check the users roles
var isAdmin = g_user.hasRole('admin');

//variables get control of the field and then store the value
var gcOrigLoc = g_form.getControl('u_original_location');
var vOrigLoc = g_form.getValue('u_original_location');
var gcNeedRep = g_form.getControl('u_need_replacement');
var vNeedRep = g_form.getValue('u_need_replacement');

//checks to see if the original location field is empty and user is not admin
if (vOrigLoc == "" && isAdmin == false) {

//test alert used for testing. If not testing this is disabled
//alert ("testing a script part 1")

//removes the specified fields from the form
g_form.setVisible('u_replacement_asset', false);
g_form.setVisible('u_replacement_asset.location', false);
g_form.setVisible('u_replacement_asset.install_status', false);
g_form.setVisible('u_replacement_asset.name', false);
g_form.setVisible('u_rma_ship_date', false);
g_form.setVisible('u_shipping_method', false);
g_form.setVisible('u_tracking_number', false);
g_form.setVisible('u_receive_date', false);
g_form.setVisible('u_received_by', false);

//checks to see if needs replacement is no and if user is admin
} if (vNeedRep == "2" && isAdmin == false) {

//test alert used for testing. If not testing this is disabled.
//alert ("testing a script part 2")

//removes the specified fields from the form
g_form.setVisible('u_replacement_asset', false);
g_form.setVisible('u_replacement_asset.location', false);
g_form.setVisible('u_replacement_asset.install_status', false);
g_form.setVisible('u_replacement_asset.name', false);
g_form.setVisible('u_rma_ship_date', false);
g_form.setVisible('u_shipping_method', false);
g_form.setVisible('u_tracking_number', false);
g_form.setVisible('u_replacement_asset_text', false);

//checks to see if needs replacement is yes and origional location is filled in.
} if (vNeedRep != "2" && vOrigLoc != "") {

//test alert used for testing. If not testing this is disabled
//alert ("testing a script part 3")

//un-hides the specified fields
g_form.setVisible('u_replacement_asset_text', false);

}
}


Not applicable

Automation of the forms CONT.


Another work flow script to keep people honest. This script disables the replacement asset fields when the affected asset field is changed. It keeps the user from changing the affected asset and then submitting the asset as a completed RMA process. There is a warning that will pop up if this change takes place.

Client Script: BCF RMA disable rep asset onchange CS8

**Script Code**


//Script created by Jeff Bloyer
//Apr 16 2007
//This script is used to disable the replacement asset fields when affected asset is not filled in or has been changed.


function onChange(control, oldValue, newValue) {

//variables that check the users roles
var isAdmin = g_user.hasRole('admin');

//checks to see if the values do not match and use is not an administrator
if (oldValue != newValue && isAdmin == false && oldValue != "") {

alert ('You need to fix the current affected asset record. Please correct the In RMA process and Operational status of the old Affected asset. You will need to go to the asset in the ITIL - Configuration to correct the information.');
return false;

//Clears and removes the fields that should not be adjusted.
g_form.setValue('u_replacement_asset', "");
g_form.setVisible('u_replacement_asset', false);
g_form.setVisible('u_replacement_asset.location', false);
g_form.setVisible('u_replacement_asset.install_status', false);
g_form.setVisible('u_replacement_asset.name', false);
g_form.setVisible('u_rma_ship_date', false);
g_form.setVisible('u_shipping_method', false);
g_form.setVisible('u_tracking_number', false);
g_form.setVisible('u_replacement_asset_text', true);

}
}


This script is the last of the work flow scripts. This script makes the ship date field mandatory once a replacement asset has been selected. This will force the BCF RMA change ship date script to execute changing the replacement asset location and status data in the CMDB.

Script: BCF RMA ship date mandatory onchange CS9

**Script Code**


//Script created by Jeff Bloyer
//Apr 16 2007
//This script makes the ship date field mandatory when a replacement asset is selected. This is necessary so that the user will select a new date and then the script relating to the ship date will run.

function onChange(control, oldValue, newValue) {

//checks to see if new value is not empty
if (newValue != ""){

//turns the mandatory field on for ship date
g_form.setMandatory('u_rma_ship_date', true);

//else runs if new value is empty
} else {

//turns the mandatory field off for ship date
g_form.setMandatory('u_rma_ship_date', false);
}
}


Referance:
Wiki that points to useful scripts that have already been built.
http://wiki.service-now.com/index.php?title=Useful_Scripts

Wiki that shows some client scripts that have already been created
http://wiki.service-now.com/index.php?title=Client_Scripts

Wiki that shows some business rules that have already been created.
http://wiki.service-now.com/index.php?title=Business_Rules

Wiki that shows mail scripts that have been created.
http://wiki.service-now.com/index.php?title=Client_Scripts

Wiki that shows a lot of the object models that service-now has to offer.
http://wiki.service-now.com/index.php?title=Script_Functions_and_Business_Rules


Not applicable

Polishing up the application


We need to finish up the application. Make some custom lists and add some more functionality to the navigation panel. Let's get going it is the home stretch.

You need to go to the system definition application again. This time click the link for applications. IMG 14

Find the Application that was created at the table creation screen. Ours is called Asset movement mgmt. Click the link for the application. Now you are viewing the application navigation window for the application we are working on. Img 15 is the finished application

At this point we want to create some new modules.

We created the following modules.

Labeled separator for the equipment request: Module1
Issue New Equipment request: Module2
Search Equipment Request: Module3
Not Shipped: Module4
Shipped: Module5
All Equip Requests: Module6(note: this report already exists. It is the module that was created when we created the table. I just renamed it.)

Labeled separator for the RMA: Module7
Issue New RMA: Module8
Search RMA: Module9
Not Shipped: Module10
Shipped: Module11
Not Received: Module12
No Incident: Module13
All RMA's: Module14 (note: this report already exists. It is the module that was created when we created the table. I just renamed it.)

The finished product should look like this. Img 16


Not applicable

Place holder just in case I need to add something later.


Not applicable

That's one seriously detailed tutorial.

Nice!

--- Pat