Advent Calendar Door 13: Turn any SharePoint field into a calculated field
Turn any SharePoint field into a calculated field
Capabilities and limitations of the standard SharePoint calculated fields are well known, and all SharePoint developers and solution creators learned to live with them. But, imagine if we could turn *any* SharePoint field into a calculated field, regardless of the field type, and complexity of the calculation? Store a dynamically generated HTML code in a Multiline text (Note) field? Check.
Complex math calculations in numeric fields? Check. Any kind of date-time fiddling with the date fields? Check. Dynamically populate users in the User field? Dynamically set metadata field? Of course. And we could go on like this as long as we want. Because it is all possible with skybow Solution Studio.
- Open the list where the desired calculated field is stored
- Go to “Things in Background” => Field settings icon => “Values” tab
- Choose the “fx Expression” calculated type, and create calculated field expression, as simple, or as complex as you need, with skybow Expression Builder.
In the case in the screenshot above, we are creating a dynamically formatted Multiline Text field which shows an icon and basic item data in a nicely styled format.
Please note that you should exclude the calculated fields from new and edit forms. If you leave them there, and user changes their value through custom input, it will have no impact since the field value will be overwritten asynchronously immediately upon saving, and user will probably be confused by the result.
Tip: if you would still like to include those fields in new and edit form, just for the presentation purposes, make them read only, and copy the same calculation formula from “things in background” into the field calculated value in the form itself. That way, user will get the effect of the calculated value being “recalculated” on the fly (as the values of the other fields are entered), and we will have no consistency issues, since the value displayed dynamically will be the same as the one recalculated in the background.