1

This is my first time that I am using BCS via a web part and in general.

this is my code and I am getting the following error: The given dot notation 'CustomerID' refers to a node in Type Descriptor structure that does not exist.

valueDictionary["CustomerID"] = CustomerID.Text; <-- I get Error here.

Anyone has any idea how to solve it or has any suggestions?

protected void btnInsertNewItem_Click(object sender, EventArgs e)
        {
            try
            {
                using (new SPServiceContextScope(SPServiceContext.GetContext(SPContext.Current.Site)))
                {
                    // Get the BDC service and metadata catalog.
                    BdcService service = SPFarm.Local.Services.GetValue<BdcService>(String.Empty);
                    IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);

                    // Get the entity using the specified name and namespace.
                    IEntity entity = catalog.GetEntity(EntityNamespace, EntityName);
                    ILobSystemInstance LobSysteminstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;

                    // Get the fields on the entity.
                    IView createView = entity.GetCreatorView("CreateCustomer");
                    IFieldValueDictionary valueDictionary = createView.GetDefaultValues();

                    // Set the values of the entity fields.
                    valueDictionary["CustomerID"] = CustomerID.Text; <-- I get Error here. it seems something is wrong with the code above.
                    valueDictionary["CompanyName"] = CompanyName.Text
                    valueDictionary["ContactName"] = ContactName.Text;
                    valueDictionary["ContactTitle"] = ContactTitle.Text;
                    valueDictionary["Address"] = Address.Text;
                    valueDictionary["City"] = City.Text;
                    valueDictionary["Region"] = Region.Text;
                    valueDictionary["PostalCode"] = PostalCode.Text;
                    valueDictionary["Country"] = Country.Text;
                    valueDictionary["Phone"] = Phone.Text;
                    valueDictionary["Fax"] = Fax.Text;

                    // Call the creator method and display the returned
                    // Customer ID.
                    Identity id = entity.Create(valueDictionary, LobSysteminstance);

                    DossierID.Text = id.GetIdentifierValues().GetValue(0).ToString();


                    StatusLabel.Text = "Customer successfully created.";
                }
            }
            catch (Exception ex)
            {

                StatusLabel.Text = "Unable to create customer." + ex.Message;
            }

        }

Here are the parameters:

<Parameters>
                <Parameter Direction="In" Name="CustomerID">
                  <TypeDescriptor TypeName="System.String" LobName="CustomerID" CreatorField="true" IdentifierName="CustomerId" Name="CustomerId" DefaultDisplayName="CustomerID" />
                </Parameter>
                <Parameter Direction="In" Name="CompanyName">
                  <TypeDescriptor TypeName="System.String" CreatorField="true" Name="CompanyName" />
                </Parameter>
                <Parameter Direction="In" Name="ContactName">
                  <TypeDescriptor TypeName="System.String" CreatorField="true" Name="ContactName" />
                </Parameter>
                <Parameter Direction="In" Name="ContactTitle">
                  <TypeDescriptor TypeName="System.String" CreatorField="true" Name="ContactTitle" />
                </Parameter>

..

10
  • 1
    Have you checked that "CustomerID" property is properly written in the Type Descriptor/entity? Apr 11, 2013 at 12:04
  • Hi Alex, that's a good question but how do I check that?
    – Imir Hoxha
    Apr 11, 2013 at 12:13
  • 1
    you have a custom bcs solution that you created? Apr 11, 2013 at 12:14
  • I created in via SharePoint designer. I simply created a wcf and added it as BCS in SPD.
    – Imir Hoxha
    Apr 11, 2013 at 12:16
  • 1
    Yes that's what i meant,have you also checked in your parameter configuration? here's a pic: lh6.ggpht.com/_SDxNQGpww6E/S1dHK-NXkxI/AAAAAAAABcU/P-hqRHa-zwM/… Apr 11, 2013 at 12:48

1 Answer 1

1

Check in your parameter configuration ,here's a pic:

enter image description here

2
  • Alex, one more thing. I am using Customers table in Northwind database as example. Customers table has only two columns that do not allow null, CustomerID and CompanyName. Now, when I try to insert a new row into Customers Table via BCS and I supply a value for both columns, but not for the rest of the columns, BCS complains that I have not supplied the values for the rest of the columns. Why do I have to supply a value for all columns? How can i suppress this error and allow insertion of a new row but supplying only values for those columns that are required? Thanks again
    – Imir Hoxha
    Apr 11, 2013 at 13:25
  • this is strange, I have never got this kind of error Apr 11, 2013 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.