Heads up, this is very much a beginner question.
My SharePoint experience is primarily with working with SharePoint designer and powershell. I've never touched Visual Studio or anything to use custom code with SharePoint.
I'm wanting to add this code:
/// <summary>
/// Sets the value of an SPBusinessDataField to the newValue.
/// </summary>
/// <param name="item"></param>
/// <param name="fieldInternalName"></param>
/// <param name="newValue"></param>
public static void SetExternalFieldValue(this SPListItem item, string fieldInternalName, string newValue)
{
if (item.Fields[fieldInternalName].TypeAsString == "BusinessData")
{
SPField myField = item.Fields[fieldInternalName];
XmlDocument xmlData = new XmlDocument();
xmlData.LoadXml(myField.SchemaXml);
//Get teh internal name of the SPBusinessDataField's identity column.
String entityName = xmlData.FirstChild.Attributes["RelatedFieldWssStaticName"].Value;
//Set the value of the identity column.
item[entityName] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { newValue });
item[fieldInternalName] = newValue;
}
else
{
throw new InvalidOperationException(fieldInternalName + " is not of type BusinessData");
}
}
as an extensions method for SPListItem.
How do I go about doing that? Is this achieved using Visual Studio? I can't seem to find any information for complete beginners about how to go about doing this.
Any advice or a push in the right direction would be much appreciated.