How to add a calculated field for a newbie

scotty81
Kilo Contributor

Hi,

 

I'm looking on some basic "how to" to add a calculated field to a table.   I know a bit of how to do this, but I did not find anything like this in the Wiki.   I've got the Eureka version.   I know that generally one creates a new field on the form view and then specifies exactly what the calculation field does in the dictionary entry. I also know some basic scripting syntax.

 

For simplicity's sake, let's say I want to calculate the duration between the open and close of a ticket.   I know that this already exists, but I'm just using it as an example.   By the time I get to the corresponding dictionary entry for my calculated field, I knew to click on the tab that said something like "Calculations" to actually enter my script.   But, in the particular calculated field I created, that did not happen.   I navigated to the appropriate dictionary entry, and instead of there being a tab inside that entry called 'Calculations', there was a tab there instead that said 'Default Value'.   So, that tells me that somewhere I did not tell Service Now that I want to enter a calculation, not just a value for this new field I want to create.

 

Can anyone tell me where one sets this?   I'm sure the part of what I'm missing is rather a simple configuration step, but I haven't figured out a way to get this to work.

 

Thanks in advance.

 

Scotty

5 REPLIES 5

williamsun
Mega Guru

There is one thing I like to do when trying to find "similar" ways to do something or "best practices".


I check what is done like it in out-of-the-box examples.


For calculated fields you would


  1. go to your dictionary table (sys_dictionary.list in the navigator filter will take you there)
  2. Add a filter for "Calculated is true"
  3. Add a filter for the type of field you are interested in (Add a filter for "Type is Duration" for example)


Now you can take a look at any out of the box fields that are using calculations for that type of field, how they work, and you even have a base script to work from.


NOTE: Make sure to not save or update these, just copy any info you want to replicate.