3

I want to create a programmatically calculated field for Sharepoint 2010 using Visual Studio 2010 in C# language.

Is there a way to set a formula that will call to my own function and return a result back to the field?

My scenario:

  • let's say I want to create a field that always returned the sum between two other fields,
  • but I don't want to use something like "=sum([filed1],[field2])".
  • I want to call to function "calc2Fields()" and return a result.

Is it possible?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
gadym
  • 125
  • 3
  • 17

2 Answers2

0

No, it is not possible. By changing the formula you are not adding any internal logic, so the field will not know what to do with your function. You can however build a custom field and incorporate there any logic you need. Of course it is not going to be identical to the built-in calculate field, but then you can add your own functions.

Vladi Gubler
  • 2,458
  • 1
  • 13
  • 15
  • thanks but , can i create a custom field that allways "refresh" it selfs like a calculated field ? – gadym Feb 22 '11 at 10:23
  • you can create a field that will recalculate its value each time the item is saved, is that good enough? – Vladi Gubler Feb 28 '11 at 16:38
  • is there any reference to your option ? how do i do that ? – gadym Mar 06 '11 at 14:31
  • this is a good start:http://vspug.com/nicksevens/2007/08/31/create-custom-field-types-for-sharepoint/ you need to insert your code into the Value property override of the rendering control, this is the property that gets called when the frameworks gets the field value and stores it in the DB. – Vladi Gubler Mar 07 '11 at 09:27
0

You will have to create your own custom field with this logic in.

Customizing the User Experience of SharePoint: Custom fields deep dive

Ryan
  • 23,871
  • 24
  • 86
  • 132