Auto Calculate the field value and store in the another filed

Madhuavandhy
Tera Contributor

I am new  to the ServiceNow platform please help me out.

I have 4 column consider A,B,C,D. If I enter value in A and B column It need to auto calculate the two filed value and result value will show in the output Filed.

 

4 REPLIES 4

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Madhuavandhy  this is pretty much easy as you need to use function field see below document

https://docs.servicenow.com/en-US/bundle/utah-platform-administration/page/build/platform-functions/...

 

Please mark my answer Helpful/Correct

Regards,

Siddharam

 

 

Arun_S1
Tera Guru
Tera Guru

@Madhuavandhy You can use Business Rules to perform your Business Logics. Write an Insert/Update Business Rule with the required logic.

 

Example:-

current.total= current.a+current.b+current.c+current.d+current.e;

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.

Ankit Rawat
Giga Guru

Hi @Madhuavandhy ,

 

Create a Before Insert and Update Business Rule.

 

Then in advance write this script.

 

var a=current.a;
var b = current.b;
var totalLCAllocation=a+b;
current.total_lc_allocation=totalLCAllocation;

 

Regards,

Ankit

Grzegorz Kaznoc
Tera Contributor

You can easly calculate value of fields by creating simple business rule BEFORE insert and update checked. Check Advanced checkbox and write code to calculate value of your fields. You can perform any operaion you need using javascript.

 

 

current.u_field_name_c =parseInt(current.u_field_name_a) + parseInt(current.u_field_name_b);
current.u_field_name_d = parseInt(current.u_field_name_a) -  parseInt(current.u_field_name_b);