web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Entity Id must be specified for Update

(0) ShareShare
ReportReport
Posted on by

Hi,

I am getting below error while updating my entity using datagrid in asp.net,

[FaultException`1: Entity Id must be specified for Update]

please help me to resolve this.

Thanks.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    it seems you did not add entity guid in the entity object that you posted.

    for example in below sample code it updates  specific account  record by specifying accountid.

    Entity existingAccount = new Entity("account");

           // Most important attribute to fill is the entity id

           // This is a GUID column from CRM. Without this

           // column you can't update records in CRM.

           existingAccount["accountid"] = Row.AccountId;

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at
    Hi Chitra,

    Thanks for reply,

    Actually, this is my code i have added public  GUID Id;

    public Guid Id;
    protected void dg_IntelCRM_UpdateCommand(object source, DataGridCommandEventArgs e)
            {
                var crmService = CRMConnection.GetCRMService();
    
              //  intelCRM["new_intelcrmquotationid"] = 
                 
                 System.Web.UI.WebControls.TextBox linenoBox = e.Item.FindControl("tb_editno") as System.Web.UI.WebControls.TextBox;
                 if (linenoBox != null)
                {
                    string line_number = linenoBox.Text;
                    intelCRM.Attributes["new_name"] = line_number;
                    
                }
                else
                {
                    Response.Write("<script>alert('Error:Null Value ')</script>");
                }
    crmService.Update(intelCRM);
               
    
                // Switch out of edit mode.
                dg_IntelCRM.EditItemIndex = -1;
             // dg_IntelCRM.DataBind();
                fillgrid();
    }


    please, help me to resolve this.

    Thanks.

  • Royal King Profile Picture
    27,686 on at

    how do you get intelCRM object ?  check intelCRM object contains value for attribute with name "new_intelcrmquotationid" if not you have to add that attribute in order to update record.

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    yeah i have created IntelCRM object,

    Entity intelCRM = new Entity("new_intelcrmquotation");

    is there any need to add intelCRMID attribute to my datagrid or without adding it how can i get the ID?

    Please help me .

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    without unique identifier you could update a record if you have implemented alternate key for the entity. Alternatekey should be unique and you could use this value to update record without guid of a record.

    Otherwise you need to pass guid of a record to update. You can add guid of the record as grid view column and set property to be hidden.

    You can find more on this topic here

    https://mahenderpal.wordpress.com/2015/06/11/using-alternate-key-to-update-entity-record-microsoft-dynamics-crm-update-1/

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    is it necessary to add guid to the update function?

    if it is necessary then how to add it in my update function.

  • Royal King Profile Picture
    27,686 on at

    if  you add guid to the grid it will be very easy to access and set that value when you want to update the record.

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    i have added it to my datagrid and it is displaying too,  but still am getting same error.

    here is my code:

    protected void dg_IntelCRM_UpdateCommand(object source, DataGridCommandEventArgs e)
    
           {
    
               var crmService = CRMConnection.GetCRMService();
    
                System.Web.UI.WebControls.TextBox guidBox = e.Item.FindControl("tb_editguid") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox linenoBox = e.Item.FindControl("tb_editno") as System.Web.UI.WebControls.TextBox;
    
                if (linenoBox != null)
    
               {
    
                   string line_number = linenoBox.Text;
    
                   intelCRM.Attributes["new_name"] = line_number;
    
               }
    
               else
    
               {
    
                   Response.Write("<script>alert('Error:Null Value ')</script>");
    
               }
    
                System.Web.UI.WebControls.TextBox itmcodeBox = e.Item.FindControl("tb_editcode") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox itmdescBox = e.Item.FindControl("tb_editdesc") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox qtyBox = e.Item.FindControl("tb_editqty") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox unitBox = e.Item.FindControl("tb_editunit") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox noofappBox = e.Item.FindControl("tb_editno_of_app") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox unitpriceBox = e.Item.FindControl("tb_editunitprice") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox discountBox = e.Item.FindControl("tb_editdis") as System.Web.UI.WebControls.TextBox;
    
                System.Web.UI.WebControls.TextBox netPriceBox = e.Item.FindControl("tb_editnetprice") as System.Web.UI.WebControls.TextBox;
    
               // Extract the data from the Textbox to string.
    
               string id = guidBox.Text;
    
               Guid guid = new Guid(id);
    
               string itemcode =itmcodeBox.Text;
    
               string itemdesc = itmdescBox.Text;
    
               int quantity = Convert.ToInt32(qtyBox.Text);
    
               int unit = Convert.ToInt32(unitBox.Text);
    
               string no_of_app = noofappBox.Text;
    
               decimal unitprice = Convert.ToDecimal(unitBox.Text);
    
               decimal discount = Convert.ToDecimal(discountBox.Text);
    
               decimal netPrice = Convert.ToDecimal(netPriceBox.Text);
    
               // Use quantity to update the data source.
    
               decimal val = quantity * unitprice;
    
               decimal totalPrice = val - discount;
    
               // Used to update the data source.
    
               intelCRM.Attributes["new_itemcode"] = itemcode;
    
               intelCRM.Attributes["new_itemdescription"] = itemdesc;
    
               intelCRM.Attributes["new_quantity"] = quantity;
    
               intelCRM.Attributes["new_numberofapplications"] = unit;
    
               intelCRM.Attributes["new_unit"] = no_of_app;
    
               intelCRM.Attributes["new_discount"] = unitprice;
    
               intelCRM.Attributes["new_unitprice"] = discount;
    
               intelCRM.Attributes["new_netprice"] = totalPrice;
    
                crmService.Update(intelCRM);
    
               // Switch out of edit mode.
    
               dg_IntelCRM.EditItemIndex = -1;
    
            // dg_IntelCRM.DataBind();
    
               fillgrid();
    
           }


    Thanks

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    you are getting the guid but not passing to crm . add below line of code  next to

       intelCRM.Attributes["new_itemcode"] = itemcode;

    intelCRM.Attributes["new_intelcrmquotationid"] = guid ;

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    Now its giving this error

    "Incorrect attribute value type System.String"

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans