Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>

..

share|improve this question
1  
Have you checked that "CustomerID" property is properly written in the Type Descriptor/entity? –  Alex Choroshin Apr 11 '13 at 12:04
    
Hi Alex, that's a good question but how do I check that? –  Helm Ifort Apr 11 '13 at 12:13
1  
you have a custom bcs solution that you created? –  Alex Choroshin Apr 11 '13 at 12:14
    
I created in via SharePoint designer. I simply created a wcf and added it as BCS in SPD. –  Helm Ifort Apr 11 '13 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/… –  Alex Choroshin Apr 11 '13 at 12:48
show 5 more comments

1 Answer

up vote 1 down vote accepted

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

enter image description here

share|improve this answer
    
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 –  Helm Ifort Apr 11 '13 at 13:25
    
this is strange, I have never got this kind of error –  Alex Choroshin Apr 11 '13 at 13:33
    
Anyway, thanks a lot for your help. –  Helm Ifort Apr 11 '13 at 13:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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