SharePoint - get value of calculated field without manual parsing

巧了我就是萌 提交于 2019-11-29 06:31:05

You have to cast it to an SPCalculatedField:

SPFieldCalculated cf = (SPFieldCalculated)myItem.Fields["CIDandTitle"];
string value = cf.GetFieldValueForEdit(myItem["CIDandTitle"]);

or

string value = cf.GetFieldValueAsText(myItem["CIDandTitle"]);

The answer given by @Nathan does not specify that you need to provide the display name of the field. It wont work with internalName. Moreover, I'm likely to use as to cast the result.

var cf = list.Fields["calculatedfieldDisplayName"] as  SPFieldCalculated;
String value = cf.GetFieldValueAsText(item["calculatedfieldDisplayName"]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!