Hi,
I have a situation where I need to recalculate roll-up field when ever a child records are Created, Updated, Deleted, I do it based on parent Id in child record.
Following is by code, When I debugged this code, its executing fine, but roll-up field is not getting refreshed.
var myEntity = (Entity)localContext.PluginExecutionContext.PostEntityImages["OpportunityProduct"];
Entity rollupEntity = localContext.OrganizationService.Retrieve("new_myrollupentity", ((EntityReference)myEntity.Attributes["myrollupentityid"]).Id, new ColumnSet("new_totalcost"));
CalculateRollupFieldRequest rollupRequest =
new CalculateRollupFieldRequest { Target = new EntityReference("new_myrollupentity", ((EntityReference)myEntity.Attributes["myrollupentityid"]).Id), FieldName = "new_totalcost" };
CalculateRollupFieldResponse response = (CalculateRollupFieldResponse)localContext.OrganizationService.Execute(rollupRequest);
rollupEntity = response.Entity;
localContext.OrganizationService.Update(rollupEntity);
Any one have faced similar problem? Any solution for this ?
Thanks in advance for your time and help...
Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.