Problem with Fetch

Mar 31, 2014 at 11:00 AM
Hi!

I have the problem with the fetch. If I paste it in code, I recieve the mistake


Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Object reference not set to an instance of an object.Detail:
<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>
<KeyValuePairOfstringanyType>
  <d2p1:key>SubErrorCode</d2p1:key>
  <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Object reference not set to an instance of an object.</Message>
<Timestamp>2014-03-31T09:58:45.4932998Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>

[EasyPlugins: EasyPlugins.SynchronousPostUpdateStep]
[9fdef62f-16f3-e211-8a5d-080027865fa2: EasyPlugins.SynchronousPostUpdateStep: Update of any Entity]


</TraceText>
</OrganizationServiceFault>

Fetch:


<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="new_productsalesplan">
<attribute name="new_productsalesplanid" />
<attribute name="new_name" />
<attribute name="new_new_salelplanid" />
<order attribute="new_name" descending="false" />
<filter type="and">
  <condition attribute="new_salelplanid" operator="eq" uitype="new_salesplan" value="{#Id}"/>
</filter>
</entity>
</fetch>

Could you help me please?
Coordinator
Mar 31, 2014 at 12:02 PM
Hi,

Is attribute 'new_new_salelplanid' correct on 'new_productsalesplan' entity ?

Amine
Mar 31, 2014 at 12:14 PM
Yes, it is OK.

Update: I think the problem is with combination of requests and attributes in one calculation. If I use only requests/ only attributes everything is OK. Are there restrictments?
I try to solve the task:
-fetch chiled entities using id of parent entity
-get the sum of fileds from child entities and save it in parent entity field.

for this issue I use fetch and parent entity attribute that stores final sum.
Coordinator
Apr 3, 2014 at 6:52 AM
Hi,

You can have the sum directly from fetchxml by choosing only one numeric attribute on the fetchxml and choose Sum aggregation function (on the bottom of the page)

Amine