Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin Error while updating money field

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am encountering a strange issue with updating a money field on CRM, I am trying to update a money field on a linked entity by trying to retrieve that field, when I am doing that via plugin I get the following error

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.Detail: 
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ActivityId>48a59228-c124-420e-87b7-f04263a13c6a</ActivityId>
<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>Index (zero based) must be greater than or equal to zero and less than the size of the argument list.</Message>
<Timestamp>2018-07-02T16:26:19.7398323Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource>PluginExecution</ExceptionSource>
<InnerFault i:nil="true" />
<OriginalException>Microsoft.Xrm.Sdk.InvalidPluginExecutionException
at Hsl.Wendys.Crm.Plugins.Commitment.AwardCommitment.ExecuteAction()
at Hsl.Xrm.Sdk.Plugin.PluginBase.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.&lt;&gt;c__DisplayClass8.&lt;Execute&gt;b__1()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IOrganizationServiceFactory organizationServiceFactory, Dictionary`2 sandboxServices, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext, Boolean enablePluginStackTrace, Boolean chaosFailAppDomain)
at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter&amp; workerCounter, Boolean returnTraceInfo)</OriginalException>
<TraceText>
An exception has occurred in the [Hsl.Wendys.Crm.Plugins.Commitment.AwardCommitment].
An invalid operation has occurred during the execution of the plugin.
{Microsoft.Xrm.Sdk.InvalidPluginExecutionException} from {Hsl.Wendys.Crm.Plugins} - Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at Hsl.Wendys.Crm.Plugins.Commitment.AwardCommitment.ExecuteAction()
at Hsl.Xrm.Sdk.Plugin.PluginBase.Execute(IServiceProvider serviceProvider)

</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.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.ExecuteAndReturnTraceInfo(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxPlugin.Execute(SandboxClient client, SandboxCallTracker callTracker, IExecutionContext requestContext, String assemblyContents, Boolean returnTraceInfo)
at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)

while this error occurs I see there are two scenarios output one in which the expected update occurs but still the error is thrown out and the second one only error occurs and the money field update doesn't happen, this is happening consistently and debugging the code is showing that the field I'm trying to retrieve is not available at run time to actually update the values in it 

Entity budgetLine = new Entity(target.LogicalName);

//this.Context.SystemOrgService.Retrieve(Constants.LineItem.EntityName, target.Id, new ColumnSet(attrName));
budgetLine.Id = target.Id;

budgetLine[attrName] = new Money(value);
this.Context.UserOrgService.Update(budgetLine); - this throws the error "Index (zero based) must be greater than or equal to zero and less than the size of the argument list."


But the attrName which I'm trying to update is getting updated with value sometimes. This all sprang up after checking this functionality is working fine and froze the code within a span of 8 hours post that the exact same code is throwing this error, I'm unable to figure out the root cause any suggestions or advice is appreciated 

pluginError1CRM.png

Thanks,

Vinod Pagadala

*This post is locked for comments

  • Johnny Gong Profile Picture
    Johnny Gong 6,482 on at
    RE: Plugin Error while updating money field

    Hi,

    Have you ever tried to debug your plugin by Plugin Registration Tool via Plug-in Profile?

    You could refer to the following video for more debugging process.

    https://www.youtube.com/watch?v=zTM2l-J6opk

    Hope it would help.

    Regards

    Johnny

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Plugin Error while updating money field

    Hi Vinod,

    Please try using the code below.

                Entity budgetLine = this.Context.SystemOrgService.Retrieve(Constants.LineItem.EntityName, target.Id, new ColumnSet(true));
                if (budgetLine.Attributes.Contains(attrName))
                    budgetLine[attrName] = new Money(value);
                else
                    budgetLine.Attributes.Add(attrName, new Money(value));
                this.Context.UserOrgService.Update(budgetLine);

    Hope this helps.

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Plugin Error while updating money field

    Hello,

    As suggested debug your code and check what causing this issue, you can follow instruction here to debug your plugin: http://himbap.com/blog/?p=2469

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Plugin Error while updating money field

    Hello,

    I believe you should troubleshoot following plugin that causes issue - Hsl.Wendys.Crm.Plugins.Commitment.AwardCommitment

    Good luck.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans