Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

IOrganizationService.update(entity ) is Deleting the Object instead of Updating Entity object.

(0) ShareShare
ReportReport
Posted on by 240

Hello All,

I am to Update the Entity Record ,Using IOrganizationService.Update() ,When I try  to Update the Object ,I dont getting Any error,It executing without any issue.

I am using Xrm(early bound)

I have Entity Called "amc01_employeetest"  it Custom Entity .I written Following code 

Protected  void  update ()

{

private static IOrganizationService _IOrgService;
static CrmServiceClient crmServiceClient;

crmServiceClient = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRMServer"].ToString());

_IOrgService = crmServiceClient.OrganizationWebProxyClient != null ? (IOrganizationService)crmServiceClient.OrganizationWebProxyClient : (IOrganizationService)crmServiceClient.OrganizationServiceProxy;

var x = radGridEmployee.MasterTableView.Items[e.Item.ItemIndex];
amc01_employeetest employeeTestUpdate = new amc01_employeetest();

employeeTestUpdate.amc01_name = txtLastName.Text;
employeeTestUpdate.amc01_LastName = txtName.Text;
employeeTestUpdate.Id = new Guid(x["amc01_employeetestId"].Text);

_IOrgService.Update(employeeTestUpdate);

}

Please help me out what is Mistake here and I tried with "ServiceContext" it Happens Same.

*This post is locked for comments

  • Sairam89 Profile Picture
    Sairam89 240 on at
    RE: IOrganizationService.update(entity ) is Deleting the Object instead of Updating Entity object.

    Code which i written....Perfectly  alright but....Some Workflow Deleting the Record in the CRM ....I tried With Some Other CRM ...It is Working Perfectly Fine.

  • Verified answer
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,401 on at
    RE: IOrganizationService.update(entity ) is Deleting the Object instead of Updating Entity object.

    Hi

    The code looks alright.

    Please try late binding as I am not sure about the name generated for early binding.

    If you are using sample, it would delete automatically. So, please check, is there any code deleting after your update operation.

    Comment that code.

    ===============Your Code with early binding=============================

    var x = radGridEmployee.MasterTableView.Items[e.Item.ItemIndex];
    amc01_employeetest employeeTestUpdate = new amc01_employeetest();

    employeeTestUpdate.amc01_name = txtLastName.Text;
    employeeTestUpdate.amc01_LastName = txtName.Text;
    employeeTestUpdate.Id = new Guid(x["amc01_employeetestId"].Text);

    _IOrgService.Update(employeeTestUpdate);

    =================Modified code for testing with late binding================

    var x = radGridEmployee.MasterTableView.Items[e.Item.ItemIndex];
    Guid employeetestId = new Guid(x["amc01_employeetestId"].Text); 
                Entity employeetest= new Entity("amc01_employeetest", employeetestId);
                employeetest.Attributes["amc01_name"] = txtName.Text;;
                employeetest.Attributes["amc01_LastName"] = txtLastName.Text;
                IOrgService.Update(employeetest);
  • Suggested answer
    M I Mostafa Profile Picture
    M I Mostafa 4,257 on at
    RE: IOrganizationService.update(entity ) is Deleting the Object instead of Updating Entity object.

    Hi there,

    If you are updating the record, you should not be generating a new Id (GUID). You should be updating the same record using its ID. If you are creating a record, you also do not need to specify the ID, Dynamics CRM does that for you.

    The following link has all information you may need:

    msdn.microsoft.com/.../gg334754.aspx

    Hope this helps! Please check "verify answer" if this response has helped you.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans