Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Workflow Extension Error

$
0
0

I am getting this error log for the following workflow extension code and have no idea how to fix the problem.  Is there any ideas out there?

Started the Average Child Fields On Parent Workflow Extension
In the Average Child Fields On Parent Model Hydrator
Run in context
Retrieved the Fixed Minimum Rent Records from the database
Total Rent Models Value: 5
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 18.0000
Sub-Total Annual Value: 55026.0000
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 36.5400
Sub-Total Annual Value: 111702.7800
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 55.6400
Sub-Total Annual Value: 170079.8600
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 75.3100
Sub-Total Annual Value: 230208.2600
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 95.5700
Sub-Total Annual Value: 292140.5100
Total PSF Value: 95.5700
Total Annual Value: 292140.5100
Parent Id: c94c3f11-042e-432f-ab30-1661aaa44b01, Parent Logical Name: po_lpg, Total PSF: 95.5700, Total Annual: 292140.5100, Total Rent Models: 5, Entity Type: LPG
Completed model hydration
Average PSF: 19.1140
Average Annual: 58428.1020
Average Fields are set
Updated The Object

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: ERROR: An error occurred in the Average Child Fields On Parent Workflow Extension. It failed to complete. The exception message was: An error has occurred in the Average Child Fields On Parent Worker. The Exception message is: An error occured while processing this request.Detail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:int">0</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>SubErrorCode</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:int">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>ERROR: An error occurred in the Average Child Fields On Parent Workflow Extension. It failed to complete. The exception message was: An error has occurred in the Average Child Fields On Parent Worker. The Exception message is: An error occured while processing this request.</Message>
<Timestamp>2016-12-29T22:39:03.8612381Z</Timestamp>
<ExceptionSource>PluginExecution</ExceptionSource>
<InnerFault i:nil="true" />
<OriginalException>Microsoft.Xrm.Sdk.InvalidPluginExecutionException
at System.Activities.WorkflowApplication.Invoke(Activity activity, IDictionary`2 inputs, WorkflowInstanceExtensionManager extensions, TimeSpan timeout)
at System.Activities.WorkflowInvoker.Invoke(Activity workflow, IDictionary`2 inputs, TimeSpan timeout, WorkflowInstanceExtensionManager extensions)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, String customActivityTypeName, IExecutionContext requestContext, Dictionary`2 sandboxServices)
at Microsoft.Crm.Sandbox.SandboxWorker.ExecuteCustomWorkflowActivity(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException>
<TraceText>
Started the Average Child Fields On Parent Workflow Extension
In the Average Child Fields On Parent Model Hydrator
Run in context
Retrieved the Fixed Minimum Rent Records from the database
Total Rent Models Value: 5
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 18.0000
Sub-Total Annual Value: 55026.0000
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 36.5400
Sub-Total Annual Value: 111702.7800
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 55.6400
Sub-Total Annual Value: 170079.8600
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 75.3100
Sub-Total Annual Value: 230208.2600
In Attribute Helper Function: GetMoney, FieldName po_ratepsf
In Attribute Helper Function: GetMoney, FieldName po_yearly
Sub-Total PSF Value: 95.5700
Sub-Total Annual Value: 292140.5100
Total PSF Value: 95.5700
Total Annual Value: 292140.5100
Parent Id: c94c3f11-042e-432f-ab30-1661aaa44b01, Parent Logical Name: po_lpg, Total PSF: 95.5700, Total Annual: 292140.5100, Total Rent Models: 5, Entity Type: LPG
Completed model hydration
Average PSF: 19.1140
Average Annual: 58428.1020
Average Fields are set
Updated The Object
</TraceText>
</OrganizationServiceFault>

Server stack trace: 
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Crm.Sandbox.ISandboxHost.ExecuteCustomWorkflowActivityAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxCustomActivityExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxCustomActivity.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)

using System;
using System.Activities;
using System.Linq;
using System.Text;
using FCE.Utilities.CRMHelpers;
using FCE.Utilities.Factories;
using FCE.Utilities.Hydrators;
using FCE.Utilities.Models;
using FCE.Utilities.Resources;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;

namespace FCE.Utilities.Workers
{
public class AverageChildFieldsOnParentWorker : IAverageChildFieldsOnParentWorker
{
public AverageChildFieldsOnParentWorker(CodeActivityContext executionContext,
InArgument<bool> traceInfo, InArgument<bool> traceDev,
InArgument<bool> traceError)
{
var factory = new WorkflowHelperFactory();
Workflow = factory.GenerateWorkflowHelper(executionContext);
Tracer = factory.GenerateTracer(executionContext, traceInfo.Get(executionContext),
traceDev.Get(executionContext), traceError.Get(executionContext));

AttributeHelper = new AttributeHelper(Tracer);
Tracer.Info("Started the Average Child Fields On Parent Workflow Extension");

Model = new AverageChildFieldsOnParentHydrator().HydrateModel(executionContext, Tracer, Workflow);
}

private WorkflowHelper Workflow { get; set; }
private ITracer Tracer { get; set; }
private AverageChildFieldsOnParentModel Model { get; set; }
private IAttributeHelper AttributeHelper { get; set; }

public void CalculateAverages()
{
try
{
var parentEntity = (from lpg in Workflow.OrgContext.CreateQuery("po_lpg")
where (Guid)lpg["po_lpgid"] == Model.ParentId
select lpg).FirstOrDefault();

// Tracer.Info("User Id: " + Workflow.UserId.ToString());

var averagePSF = Model.TotalPSF/Model.TotalRentModels;
var averageAnnual = Model.TotalAnnual/Model.TotalRentModels;

Tracer.Dev(String.Format("Average PSF: {0}", averagePSF));
Tracer.Dev(String.Format("Average Annual: {0}", averageAnnual));

parentEntity.Attributes["po_newdeal_averagefmrpsf"] = new Money(averagePSF);
parentEntity.Attributes["po_newdeal_averagefmrannual"] = new Money(averageAnnual);

Tracer.Info("Average Fields are set");

Workflow.OrgContext.UpdateObject(parentEntity);

Tracer.Info("Updated The Object");
var errorSet = Workflow.OrgContext.SaveChanges();

if (errorSet.HasError)
{
StringBuilder errorString = new StringBuilder();
foreach (var result in errorSet)
{
if (result.Error != null)
{
errorString.AppendFormat("Error: {0}\n", result.Error.Message);
}
}
Tracer.Error(errorString.ToString());
}

Tracer.Info("Updated the LPG with the Average for PSF and Annual from the Fixed Minimum Rent entities.");

}
catch (Exception ex)
{
throw new Exception(string.Format(Constants.ExceptionMessages.AverageChildFieldsOnParentWorker.ERROR, ex.Message));
}
}
}
}


Viewing all articles
Browse latest Browse all 46379

Trending Articles