how to update record(CRM 2011) through ASP.net
-
יום שישי 23 דצמבר 2011 10:33
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.
כל התגובות
-
יום שלישי 27 דצמבר 2011 22:56
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
- הוצע כתשובה על-ידי aanch יום שלישי 03 אפריל 2012 12:36
-
יום רביעי 28 דצמבר 2011 03:53
Thanks for your reply , il check it out- סומן כתשובה על-ידי Pradeep poojary יום רביעי 28 דצמבר 2011 03:53