Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

D365 CRM Portal Error on Loading Entity Form Server Error [Solved]

Posted on by 64

[Solved - scroll down]

Hello

I've created a Portal linked to CRM D365.

I've got a page with an Entity List, which displays fine.

Selecting a record from the Entity List opens the Entity Form on its own page.

That last step works fine, but only when the Entity List view only contains 1 record. As soon as the List contains 2 or more records, I get an error when trying to open a record.

The error says "sequence contains more than one element" and a load of other stuff that I don't fully understand.

I've tried playing with the settings of the Entity List or Form, but I've not found a fix.

Has anyone experienced this and found a solution? I'd be immensely grateful to hear your suggestions.

Like I said, when the List shows only 1 record, it will open just fine; but when the List shows 2 or more, none will open.

Thanks,

Pete.

The error:

Server Error in '/' Application.


Sequence contains more than one element

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Sequence contains more than one element

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[InvalidOperationException: Sequence contains more than one element]
   System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +470
   Adxstudio.Xrm.Web.UI.WebControls.EntityForm.GetEntitySourceDefinition(OrganizationServiceContext context, Entity entityform) in S:\Framework\Adxstudio.Xrm\Web\UI\WebControls\EntityForm.cs:1201
   Adxstudio.Xrm.Web.UI.WebControls.EntityForm.CreateChildControls() in S:\Framework\Adxstudio.Xrm\Web\UI\WebControls\EntityForm.cs:578
   System.Web.UI.Control.EnsureChildControls() +107
   System.Web.UI.Control.PreRenderRecursiveInternal() +58
   System.Web.UI.Control.PreRenderRecursiveInternal() +227
   System.Web.UI.Control.PreRenderRecursiveInternal() +227
   System.Web.UI.Control.PreRenderRecursiveInternal() +227
   System.Web.UI.Control.PreRenderRecursiveInternal() +227
   System.Web.UI.Control.PreRenderRecursiveInternal() +227
   System.Web.UI.Control.PreRenderRecursiveInternal() +227
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3671
  • Nya Profile Picture
    Nya 29,056 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error [Solved]

    Hi Pete,

    Thanks for your follow up. This expanded my knowledge about Portal.

     

    Best Regards,

    Nya

  • Verified answer
    pmrsim Profile Picture
    pmrsim 64 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error

    If anyone's following this thread or comes across it in future... I logged a ticket with MS and got it resolved. I suppose, in the end it was user-misunderstanding.

    The solution:

    Both my Entity List and Entity Form had the Record Source Type set to 'Record Associated to Current Portal User'.

    "In the Entity Form If the current Record Source Type is ‘Record Associated to Current Portal User’, which means it would retrieve whole records related to current Portal user. So it would cause error ‘Sequence contains more than one element’.

    For more details, please refer to the document on it: docs.microsoft.com/.../entity-forms

    In order to fixing this issue, please change the Record Source Type from ‘Record Associated to Current Portal User’ to “Query String”."

    Thank you to Sonal at MS for solving this.

    So in the end, it was all due to the Record Source Type on the Entity Form.

    All the best,

    Pete.

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error

    Hi,

    It is recommended to create a ticket to MS for more help.

    Best Regards,

    Nya

  • pmrsim Profile Picture
    pmrsim 64 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error

    I've still not solved this and hoping someone can help.

    I have done lots of reading and I 'know' now that the issue is most likely with this:

    System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +470

    I need to change that 'SingleOrDefault' to 'FirstOrDefault', but I have no idea where this lives. Is it in a code somewhere, is it an option, a switch?

    Does anyone have any ideas on where/how I'm able to change that?

    Thanks so much,

    Pete.

  • pmrsim Profile Picture
    pmrsim 64 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error

    Thanks for the suggestion Nya. I've restarted the portal, but still no difference.  I'm wary of resetting it at this point, as it would incur a lot of extra work (and I'm fairly sure I've done this in the past and it didn't help).

    I have been trying to associate the Entity Form with different Pages/Page Templates... and at some point, the page loaded but without the Form on it.  It has since gone back to not loading at all and showing yellow screen of death.

    I found a duplicate website binding, which i resolved, but also made no difference to my issue.

    Pete

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error

    Hi Pete,

    Please try to restart or reset your portal from Power Apps if you haven't made any changes to Portal.

    Reset a portal - Power Apps | Microsoft Docs

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Nya

  • pmrsim Profile Picture
    pmrsim 64 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error

    Thanks for the reply Nya. Sadly it didn't solve it. Same error appears when browsing incognito.

    Pete.

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: D365 CRM Portal Error on Loading Entity Form Server Error

    Hi,

    Please try to access the portal with "InPrivate" or "Incognito" mode or login with another account.

    If it can work, there should be something wrong with the settings of web roles.

     

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Nya

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans