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)

Update CRM entity through code.

(0) ShareShare
ReportReport
Posted on by 795

Hi,

I am working on a requirement where in marketing list, an attribute is once true and on some execution, i want to make it false. I am setting that CRM optionset value to false through code but it doesn't reflect on my CRM entity on again execution. Using an MVC application. Can you please tell me how to send data back to CRM and reflect the changes there using C# code.

Thanks

*This post is locked for comments

I have the same question (0)
  • antc Profile Picture
    2,909 on at

    What code are you using?

    Any errors?

    Are you using bool (0, 1) / yes no / true false?

  • Suggested answer
    Mir Hassan Ali Profile Picture
    1,720 on at

    Hi

    Please look at the samples here docs.microsoft.com/.../web-api-basic-operations-sample-csharp to update data in CRM using the API

    Mir

  • CRM Beginner  Profile Picture
    795 on at

    @antc : Basically,i am using --

    entity.Id = (Guid)item.Attributes["entityguid"];

    entityid = entity.Id;

    item.Attributes["new_attributename"] = false;

    service.Update(entity);

    But, it doesn't reflect the value to CRM server.Just make the value changed to my code.

  • Suggested answer
    antc Profile Picture
    2,909 on at

    item.Attributes["new_attributename"] = false; Looks Ok

    Can you run in VS debug mode with some breakpoints to see whats happening maybe an error in other code?

  • Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    Hi,
    In your custom application, you make make an instance of the IOrganizationService using CrmServiceClient (msdn.microsoft.com/.../microsoft.xrm.tooling.connector.crmserviceclient.aspx). So in your custom application should be information for accessing your OrganizationService.

    After that in your code should be like this

    var marketing = new Entity("list", target.Id);
    marketing["attr"] = false;
    _service.update(marketing);

    Something like this.

  • CRM Beginner  Profile Picture
    795 on at

    No No, debug is working fine..And for the current instance, it updates the attribute to false.But when i am trying to re-fetch it from CRM, it doesn't reflect the updated value there..

  • Nithya Gopinath Profile Picture
    17,078 on at

    Can you post the entire code?

  • Suggested answer
    Mir Hassan Ali Profile Picture
    1,720 on at

    Hi

    You are setting the attribute value for object item but you are updating object entity hence no change in CRM. You update code should be

    service.Update(item);

  • Mir Hassan Ali Profile Picture
    1,720 on at

    Or set the attribute value for entity not item.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    Try using the code below.

    item["new_attributename"] = false;
    service.Update(item);
    

    Hope this helps.

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