External data column

May 15, 2012 at 7:46 AM

While testing the latest version on a list with a external data column, it appears that when changing the value of that column while it was empty. The new value isnt stored in properly. the new value wont show in the standard view allthough it does show in datasheet view and aswell in the view item.

after some testing it seemed like the meta data of the external data column is not stored completly. After using batch edit on the same column with values already stored in it and then refreshing the external data, the old values will be back as if the edit didnt happen.

While the rest of the editing works perfectly here, the external data column would be a very great feature if it worked. any suggestions?

Dominique

 

Jul 2, 2012 at 10:51 AM

Hey Dominique,

We've run into this problem aswell, I've updated the code of this project to make this work for external data columns aswell.
It's currently still in development, yet we have a working version.
Give me a shout

Kind regards
Denis

Sep 3, 2012 at 11:41 AM

hi Ultri,

how far is the development of the external data lists?

I can help you, because i have some code that change the value of BusinessFields. But this work only when you have one column in the external data list.

 

Nov 2, 2012 at 5:22 PM


Has any progress made in relation to batch edited external lists displaying the metadata within the standard view?

Jul 3, 2013 at 9:05 AM
Hi,

This currently still seems to be an issue. Could anyone on the team provide an update on this ?

Cheers,
Steven
Jul 3, 2013 at 9:53 PM
Edited Jul 16, 2013 at 8:17 AM
I have finished implementing the logic for the Business Data Field, the related and secondary fields. It requires a minor change to the button click logic to make sure that all BDC fields are correctly set.

Feel free to integrate this into the solution, or contact me if you want me to do it.
                        else if (control is BusinessDataFieldControl)
                        {
                            BusinessDataFieldControl bdcControl = (BusinessDataFieldControl)control;
                            SPBusinessDataField bdcField = (SPBusinessDataField)bdcControl.Field;
                            SPList list = bdcField.ParentList;

                            if (bdcControl.Value != null)
                            {
                                PickerEntity bdcItemEntity = (PickerEntity)bdcControl.GetPicker().Entities[0];
                                string bdcItemKey = bdcItemEntity.Key;
                                string bdcItemText = bdcItemEntity.DisplayText;

                                // Update the 'primary' field
                                _fieldValues.Add(new KeyValuePair<Guid, string>(bdcField.Id, bdcItemText));

                                // Update the 'related' field
                                SPField relatedField = list.Fields.GetFieldByInternalName(bdcField.RelatedField);
                                _fieldValues.Add(new KeyValuePair<Guid, string>(relatedField.Id, bdcItemKey));

                                // Update the 'secondary' fields
                                List<SPField> secFields = bdcField.GetSecondaryFields();
                                foreach (SPField secField in secFields)
                                {
                                    string bdcMappedProperty = secField.GetProperty("BdcField");
                                    _fieldValues.Add(new KeyValuePair<Guid, string>(secField.Id, bdcItemEntity.EntityData[bdcMappedProperty].ToSafeString()));
                                }
                            }
                        }
namespace TamTam.SP2010.BatchEdit.Internal
{
    public static class Extensions
    {
        public static string ToSafeString(this object obj)
        {
            string result = null;

            if (null != obj)
                result = obj.ToString();

            return result;
        }

        public static ItemPicker GetPicker(this BusinessDataFieldControl control)
        {
            ItemPicker result = null;

            if (null != control)
            {
                result = control.GetType().InvokeMember("picker", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance, null, control, null) as ItemPicker;
            }

            return result;
        }

        public static List<SPField> GetSecondaryFields(this SPBusinessDataField bdcField)
        {
            List<SPField> result = null;

            if (null != bdcField)
            {
                result = new List<SPField>();

                string secFieldNamesString = bdcField.GetProperty("SecondaryFieldsWssStaticNames");
                string[] secFieldNames = bdcField.GetType().InvokeMember("SplitSecondaryFieldNames", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, bdcField, new object[] { secFieldNamesString }) as string[];

                SPFieldCollection fields = bdcField.ParentList.Fields;

                for (int i = 0; i < secFieldNames.Length; i++)
                {
                    result.Add(fields.GetFieldByInternalName(secFieldNames[i]));
                }
            }

            return result;
        }
    }
}
Jun 30, 2016 at 9:01 PM
Edited Jun 30, 2016 at 9:14 PM
code works great!

thx