Hello,
I have an entity called new_accrued_billing that I've setup as a sub grid in the project module so you can click in the grid from within a project and create a record. My next requirement involves summing the values of 1 field in the Subgrid Records and summing them into a field on the project module. I've modified an existing plugin (that does the same thing for Time Entries on a project).
decimal Billed = 0; // decimal NonBillable_Total = 0; lastAction += "\nRun Totals For loop"; if (Project_Billing != null) { lastAction += "\nTime Entry is not null " + Project_Billing.Count.ToString(); if (Project_Billing.Count > 0) { lastAction += "\nCount is not null eric " + Project_Billing.Count.ToString(); foreach (Entity Project_Billings in Project_Billing) { Billed += (Convert.ToDecimal(Project_Billings["new_billed"].ToString())); } } } Entity updateProject = new Entity(); updateProject.LogicalName = "new_project"; updateProject.Id = parentEvent.Id; updateProject["new_billing_summary"] = Convert.ToDecimal(Billed.ToString()); // updateProject["new_nonbillabletime"] = Convert.ToDecimal(NonBillable_Total.ToString()); lastAction += "\nAttempting Update " + updateProject.Id.ToString(); try { crmService.Update(updateProject); } catch (FaultException e) { lastAction += "\nError: " + e.Message; throw new InvalidPluginExecutionException("Fault Exception: " + lastAction); } }//try try { crmService.Update(updateProject); } catch (FaultException e) { lastAction += "\nError: " + e.Message; throw new InvalidPluginExecutionException("Fault Exception: " + lastAction); } }//try
It compiles successfully and registers however I receive the following error:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Catch All Exception:tracingService setup for Project_Billing_Rollup
serviceFactory set
service set
MessageName = Create
Create Message
Comes to Billing Entry
Parent Obtained
Run Totals For loop
Time Entry is not null 3
Count is not null eric 3Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Catch All Exception:
tracingService setup for Project_Billing_Rollup
serviceFactory set
service set
MessageName = Create
Create Message
Comes to Billing Entry
Parent Obtained
Run Totals For loop
Time Entry is not null 3
Count is not null eric 3</Message>
<Timestamp>2013-05-02T20:29:43.7746617Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>
[Billing_Summary_Rollup: Project_Billing_Rollup.Project_Billing_Rollup]
[ Project_Billing_Rollup.Project_Billing_Rollup: Create of new_accrued_billing]
</TraceText>
</OrganizationServiceFault>
Any suggestions would be great!
Thanks!
Eric