Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

retrievemultiple issue

(0) ShareShare
ReportReport
Posted on by 7,316

Hi,

I am retrieving a column set using RetrieveMultiple. It used to work before correctly but then I changed some project settings in visual studio and reverted them back to old ones. Since then code started behaving differently.

 QueryExpression query = new QueryExpression
        {
            EntityName = "new_name",
            ColumnSet = new ColumnSet(new string[] { "new_firstname", "new_lastname", "new_language", "new_email", "new_primaryphone", "new_type", "new_state" }),
            Criteria = codeFilter
        };

        EntityCollection records = _orgService.RetrieveMultiple(query);

On execution 'query' has all the 7 columns but then after RetrieveMultiple execution only 6 columns are getting assigned to 'records' entity collection.

Why would that happen?

Thanks for any help!

*This post is locked for comments

  • Suggested answer
    SonicVader Profile Picture
    SonicVader on at
    RE: retrievemultiple issue

    Yep, Aileen, you have my vote for MVP.

    You always do due diligence and get to the correct answer.

    Keep up to good work, much appreciated.

  • Verified answer
    Aileen Gusni Profile Picture
    Aileen Gusni 44,522 on at
    RE: retrievemultiple issue

    If it is null, you cannnot retrieve the field value, that is what returned in the retrieve function in  CRM.

    Then you should validate whether its entity contains the attribute or not.

  • meenoo Profile Picture
    meenoo 7,316 on at
    RE: retrievemultiple issue

    Aileen, so what if the field value is null and I want to retrieve that field also?

    I think this is happening because field null values. When my code was working fine, I am sure there were no nulls. Now, I am testing with different scenarios and it is failing.

  • Suggested answer
    Hugo Silva Profile Picture
    Hugo Silva 1,374 on at
    RE: retrievemultiple issue

    Hi Meenoo,

    If this is a plugin you need to check if you done any filter criteria on the fields on the plugin register.

    <Step CustomConfiguration="" Name="DoSomething_OnPostUpdate" Description="Post-Operation for DoSomething" FilteringAttributes="FieldsToBeFiltered" Id="000AAA0A-0000-A000-00A0-00000A000A00" MessageName="Update" Mode="Synchronous" PrimaryEntityName="SomeEntity" Rank="1" SecureConfiguration="" Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly"> <Images> <Image Attributes="SomeEntity" EntityAlias="PreImage" Id="000AAA0A-0000-A000-00A0-00000A000A00" MessagePropertyName="Target" ImageType="PreImage" /> <Image Attributes="SomeEntity" EntityAlias="PostImage" Id="000AAA0A-0000-A000-00A0-00000A000A00" MessagePropertyName="Target" ImageType="PostImage" /> </Images> </Step>

  • Aileen Gusni Profile Picture
    Aileen Gusni 44,522 on at
    RE: retrievemultiple issue

    Meenoo,

    To be honest I have no idea about this except that the field values is really null.

    Because CRM will only return the records attribute that consist value, so that otherwise got object reference error.

    Especially you have did the column set to true, so it does mean we have already 'insist' the CRM to provide all of the possible fields, but if the value is blank then CRM wont be able to provide it to us.

    Let's you try using the service.Retrieve() function, take an example.

    Or try to use the FetchExpression, and also see using the odata query whether you got the email data or not.

    Thanks.

  • meenoo Profile Picture
    meenoo 7,316 on at
    RE: retrievemultiple issue

    Its a custom app.

    Okay, I gave a try like ColumnSet(true) and the email column is still missing.

  • Aileen Gusni Profile Picture
    Aileen Gusni 44,522 on at
    RE: retrievemultiple issue

    Meeno,

    This is not plugin?

    This is custom app?

    Okay, let's try to show all columns:

    ColumnSet = new ColumnSet(true)

    Thanks.

  • meenoo Profile Picture
    meenoo 7,316 on at
    RE: retrievemultiple issue

    Yes for all the records. And initially it is new_email that was missing. Then I took off that column and tried to execute it. Then another column is missing! I don't understand how to troubleshoot it.

    Bruno Lucas  The missing column does have value and it is not null. I am using CRM 2013  on prem. ANd I haven't changed anything in the filter.

    Thanks

  • Aileen Gusni Profile Picture
    Aileen Gusni 44,522 on at
    RE: retrievemultiple issue

    Menoo,

    When you said, 7 columns, only getting 6 columns, is for all of the record? And what is the  missing 1?

    THanks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: retrievemultiple issue

    Hi,

    Please check your criteria. It is modified?

    Mansoor

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans