Question about 'function calculatedFieldValue()'

tobrien
Kilo Guru

Hi,

Lately, when I add a new column to a table (usually a Text type) SNow decides that it will set the Calculation attribute to the default: function calculatedFieldValue()

I'd like to understand (1) Why is it doing this? and (2) How can I remove that attribute?

I tried the obvious by removing the contents for the Calculation attribute for the column and UPDATING .. but no joy.

Thanks !

tony

 

1 ACCEPTED SOLUTION

Hi @tobrien,   

I tried to investigate this and what I come up with is that there is onChange client script [Set Calculated Template] on the Calculated field. When calculated field value changes to true it generates a default template and put that in the calculation field. It is consistent throughout the platform regardless of field type. 

You can empty calculation field only by clearing value of calculation field in the form view and then uncheck the calculated checkbox and now save the form. From the List view we cannot empty the calculation cell value, I am not able to find any BR, ACL or onCellEdit client scripts that is restricting to empty the cell may be some internal functionality controlled by Servicenow.  

I hope this helps.

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

View solution in original post

8 REPLIES 8

sachin_namjoshi
Kilo Patron
Kilo Patron
CalculatedFieldValue() function is used to calculate field value using calculations like below
 
 
 
function calculatedFieldValue(current) {
 var total2=current.mon_2 + current.tues_2 + current.wed_2;
 return total2;

 
})(current);
 
 
 
Regards,
Sachin

Michael Jones -
Giga Sage

I've not seen the system do that by default, but I think you'd need to remove the value for the checkbox "calculated" on the dictionary entry for that field. 

As to why it is doing it...well...while you're on the dictionary entry unchecking the box, check the dictionary for that field and make sure it doesn't have a default value of true?

Hope this helps!

If this was helpful or correct, please be kind and click appropriately!

Michael Jones - Proud member of the CloudPires Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

MrMuhammad
Giga Sage

By Default Calculated checbox is unchecked for any field type. Are you creating table column from scratch or using insert & stay to create from existing? 

Howver, If you want to remove that you need to open the dictionary and under the tab Calculated value uncheck the calculated checkbox. 

 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

Regards,
Muhammad

tobrien
Kilo Guru

Thank You all for responding...

I should have mentioned that I had visited the suggested areas -- that's why this is so weird!

 

find_real_file.png

 

 

Attach #1 shows the column definition/dictionary

 

 

 

Attach #2 shows that even with #1, I still get...

 

find_real_file.png