Calculated Value

Vikram Meena
Giga Contributor

Hi,

What is the use of calculated value that is present in Dictionary Entry,Please tell me with some script 

Thanks in advance  

 

1 ACCEPTED SOLUTION

Simple algebric calculation is one of the parameters while choosing between BR and Function Fields. The function field will execute and calculate value but it doesn't store that value in the database so it means there is no history to be maintained. Its just a display value calculated and displayed every time a form/list loads. 

On the other hand, Business rule calculates and stores the value into the database which means we would have a history of value changes and better performance as it doesn't calculate value unnecessary rather on when values updated only. 

Take a look at Function Fields limitation section of the doc that has some good points that will help choose between function field and other alternatives. 

Regards,
Muhammad

View solution in original post

7 REPLIES 7

Namrata Khabale
Giga Guru

Hey  Vikram,

Calculated Value:

 

Determines whether the value of the field is calculated from other values. If selected, use the Calculation field to define how the calculation is performed. When sorting or grouping by a calculated field, the sort order is based on the field value from the last time the field was updated, not the last time the field was displayed.

Note: In relation to business rules, calculated fields are populated first before any business rule, even a before business rule, is run. Calculated fields are then populated again if necessary after any before business rules run.

 

Calculation [Advanced view]:

 

When the Calculated field is selected, allows you to enter a script for calculating the value of the field. These can be overridden for extended tables with dictionary overrides. You can use the current object in this script. As with access control rules, the script can:

  • Evaluate to true or false.
  • Return an answer variable set to true or false.
  • Set a field value directly, such as: current.display_name="name".

 

For more details refer the links:

https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/data-dictionary-t...

 

Mark Correct and Helpful, if it helps!

Best Regards,

Namrata.

Thanks for your valuable information could you also tell me the use of Function Field

MrMuhammad
Giga Sage

That provides the ability to set the value of field based on some calculation or based on other fields value. 

e.g you can set total sum of Field1 + Field2 to Field3 by using calculated value.

Please note, calculated value has adverse performance effect so we instead use client scripts or business rules as per the requirements. 

Thanks & Regards,

Sharjeel 

Regards,
Muhammad

Thanks Muhammad for your response