locked
how to update record(CRM 2011) through ASP.net RRS feed

  • Question

  • My question is not simple as it sounds in my title. let me explain,

    I have a entity called "Medical history"( both in CRM 2011 n ASP.net portal). Now, I create a record from ASP.net , in CRM, an entity will be created. everything working fine. What i really need is  I should be able to a create the record ONLY once. After creating a record from ASP, customer can ONLY update(edit ) that particular record. is there a work around for this ??!! 

    According to my Code, every time the customer click on" submit" from the ASP.net a record is created. that means.. customer can create multiple record(dis is Exactly opposite to my client requirement) . by-d-way am using "  service.Create(Medical);" to create the record. how can i restrict the customer to create ONLY ONE record and how can i update the same record every time. customer shouldn't  not be allowed to create multiple records.

     

    Friday, December 23, 2011 10:33 AM

Answers

  • Thanks for  your reply , il check it out
    • Marked as answer by Pradeep47 Wednesday, December 28, 2011 3:53 AM
    Wednesday, December 28, 2011 3:53 AM

All replies

  • Hi,

    You will have to add the logic in your code to handle the update if a record already exists. For example: the click of the Submit button.

    When you do a Service.Create(Medical); this should give you a guid/ID of the entity record that was created. you can then 'Retrieve' the record from the database & set any attribute values that you want to update & then call 'Update' method of the service/IOrganizationService.

    Something like this which updates the same record with new values for the attributes.

    Entity account = new Entity("account");
    account["name"] = "Fourth Coffee";
    _accountId = _service.Create(account);

    ColumnSet attributes = new ColumnSet(new string[] { "name", "ownerid" });
    account = _service.Retrieve(account.LogicalName, _accountId, attributes);
    account["address1_postalcode"] = "98052";
    account["revenue"] = new Money(5000000);

    _service.Update(account);

    More example is avilable in the CRM SDK documentation http://www.microsoft.com/downloads/en/details.aspx?FamilyID=420f0f05-c226-4194-b7e1-f23ceaa83b69.

    Thanks,

    RBaliga

    • Proposed as answer by aanch Tuesday, April 3, 2012 12:36 PM
    Tuesday, December 27, 2011 10:56 PM
  • Thanks for  your reply , il check it out
    • Marked as answer by Pradeep47 Wednesday, December 28, 2011 3:53 AM
    Wednesday, December 28, 2011 3:53 AM