web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Problem using Query Expression with RetrieveMultipleResponse

(0) ShareShare
ReportReport
Posted on by

Hi

I'm trying to use a query to retrieve all the invoice records that have a certain value in a custom field and then update the date delivered and the due dates, but I'm getting an error on the retrieve statement:-

Unexpected Error

An error has occurred.

I have traced the error through so I know it occurs on the RetrieveMultipleResponse.  The code is as follows:-

DataCollection<Entity> GetInvoiceItems(IOrganizationService service, InArgument<int> ISCNum)

       {

           QueryExpression qe = new QueryExpression();

           qe.EntityName = "invoice";

           qe.ColumnSet = new ColumnSet(new string[] { "datedelivered", "duedate" });

           ConditionExpression CondOppId = new ConditionExpression();

           CondOppId.AttributeName = "new_isc_id_num";  //name found in Invoice Mapping

           CondOppId.Operator = ConditionOperator.Equal;

           CondOppId.Values.Add(ISCNum);        // Can't be the same as the Atribute name.

           FilterExpression filter = new FilterExpression();

           filter.FilterOperator = LogicalOperator.And;

           filter.Conditions.AddRange(new ConditionExpression[] { CondOppId });

           qe.Criteria = filter;

           RetrieveMultipleRequest request = new RetrieveMultipleRequest();

           request.Query = qe;

           RetrieveMultipleResponse response = (RetrieveMultipleResponse)service.Execute(request);

           if (response.EntityCollection != null &&

               response.EntityCollection.Entities != null &&

               response.EntityCollection.Entities.Count > 0)

               return response.EntityCollection.Entities;

           else

               return null;

       }

   }

Does anyone have any ideas as to where I'm going wrong.  I'm quite new to Dynamics and to C#, so it is probably something very silly.  Your help is most appreciated.

Tilly

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I am using a custom workflow.  It is using an in argument because we need to be able to find all the invoices with a certain ISC number, and then reset the delivery date and due dates for those invoices.  As we don't actually deliver anything we are using these dates to show how long a client has a service and this sometimes changes.  So I have set up a dialogue to receive in the required number and then it kicks off the workflow to find all the records and update them, or it should.

    Tilly

  • Community Member Profile Picture
    on at

    Thank you.  

    That has solved my problem.  

    I had to do the same process for the input date fields, which makes sense.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans