Add fields to a form without adding them to the table.

Ivar Donado
Mega Sage

Hi guys,

I'm relatively new to Servicenow (I've been working on it around 4 months). I have a client who wants to update the vulnerable item table which contains a reference field to the vulnerability entries table. He wants to add some fields of that table (vulnerability entries) on this form, however that table in conformed of records of two tables that extend from it: Third party vulnerability entries and National Database vulnerability entries, both with different fields that resemble similar information.

Third party vulnerable entry: Summary, Severity, Threat, Solution

National DB vulnerable entry: Summary, Vulnerability score.

I was thinking I could add a few string fields and just populate them with the correct info depending on whether the record is from National DB vul. entry or Third party. vul. entry using a script, those fields will be read only for everybody anyway so there's no need to update anything on the original records. I was wondering if there's a way of adding those fields on the vulnerable Item form so I can populate them On Load/On change without actually adding them to the table.

 

1 ACCEPTED SOLUTION

Steve McCarty
Mega Guru

I don't know of a way to add string fields to a form that aren't stored in the table, but there are a couple of ways to get something similar.

The easiest way, since these are reference fields, is to use the form layout (not the form designer) and you can add in fields from related tables.  Open the vulnerable item form, click the additional actions icon at the top and choose Configure -> Form Layout from the menu.  This will bring up a list of Available and Selected fields.  In the available list highlight the reference field you want to get more information about and an icon will be added that says "Expand selected reference field" in between the Available and Selected boxes.  If you press that, it will change the Available box to show all the fields on the referenced table.  You can then highlight those fields and press the '>' button that moves the field to the Selected box.  You can then use the up and down arrows to move the field to where you want it on the form.

The other way is to use an annotation on the form with a script.  Using the form layout tool, you select the * Annotation item from the Available list and move it to the selected box where you want the annotation to be.  Highlight the annotation in the selected box and you can choose what type of annotation you want.  You will have to try the different annotation styles to see which one you want for this application.  If you set the annotation to include HTML, you can put <span id="myid"></span> into the annotation.  Then you can use an onload client script to update the span using: 

document.getElementByID('myid').innerHTML='enter your HTML code here';

I would recommend also using a display business rule to get the information you want from the other tables and adding it to the g_scratchpad object to eliminate an extra round trip to the server.  Then you can use the info in the g_scratchpad object in your client script to update your annotation.

View solution in original post

5 REPLIES 5

I understand what you mean, that's what I normally do. It's just that in this case there are fields that don't belong to the referenced table, those fields are only in the child table, that's why they won't show up n the configure layout section even by "dot walking".

 

Leaving that aside, your suggestion of using an annotation to add the field that was not on the referenced tabled worked! Thanks!