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

ok so in the list view Calculation column is showing the default function structure which has no impact on the field. This is just a dummy function wrapper. The reason it is there is that the developer must be aware of the function parameters available that can be used inside the function body. 

Again, this has no impact on the field until unless you modify the function body. It just returns the empty string. 

 

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

Thanks & Regards,

Sharjeel 

Regards,
Muhammad

tobrien
Kilo Guru

Thank You, Mr. Sharjeel ---

 

I understand that it is of no impact --- BUT why does SNow put it there sometimes, and why does it persist?

 

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

tobrien
Kilo Guru

Mr. Sharjeel,

Thanks for doing such a deep dive on this -- It was that part about NOT being able to empty the calculation in a (table columns) List View that I find most unsettling. You *think* you've removed it until you revisit the list... and it's back.

 

Thanks again,

tony