Search code examples
c#sharepoint-2013bcs

How can we set external data exposed by Business Connectivity Service (BCS) in Sharepoint 2013 Online?


I have write the code to set the external data exposed by BCS in Sharepoint 2013 using server side code. Here is the code:

    public void SetBusinessDataValue(object spItem,object spField, string value)
    {
        try
        {
            SPBusinessDataField businessDataField = spField as SPBusinessDataField;
            SPListItem spListItem = spItem as SPListItem;

            businessDataField.ParseAndSetValue(spListItem, value);  //Set your value here
            string fieldName = ((SPField)spField).Title;
            spListItem[businessDataField.RelatedField] = spListItem.Fields[fieldName];
        }
        catch (Exception ex)
        {
            Logging.LogWriteLine("Error in method SetBusinessDataValue(). Failed to set the business data value", ex);
        }
    }

It works fine. However, I was not able to write the code to set the external data in SharePoint 2013 Online using SharePoint Client Object model. Can someone help to resolve my problem?


Solution

  • Are you using sandbox solution? If yes, you can write the same server code at the sandbox solution. Please! Try it.