1
votes

Does anyone know a way using either the SharePoint 2010 Client Object Model or the SharePoint 2010 web services to evaluate the formula for a given field? For example, if I have a DateTime column whose default value is set to a formula like:

=DATEDIF([Column1], [Column2],"d")

or

=MONTH([TODAY])

I would like to be able to somehow evaluate this formula from a client application.

Thanks in advance for any help anyone can offer.

EDIT:

I am dealing specifically with DateTime calculated default values which seem to be handled differently than a typical "calculated" field.

3

3 Answers

3
votes

If you just get the value for that field it'll evaluate. The formula itself is stored in the field definition for the list.

So just getting MyListItem["MyCalculatedColumn"] will evaluate the formula.

2
votes

There is no client side way to evaluate such formula by itself using SharePoint APIs and I don't think server side API is publically available.

Your best option is to update an item and read the field back.

0
votes

You will find the answer on StackOverflow here.

The part of the object model you need is SPFieldCalculated.