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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

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

(0) ShareShare
ReportReport
Posted on by 34

[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
I have the same question (0)
  • Suggested answer
    Nya Profile Picture
    29,060 on at

    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

  • pmrsim Profile Picture
    34 on at

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

    Pete.

  • Suggested answer
    Nya Profile Picture
    29,060 on at

    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
    34 on at

    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

  • pmrsim Profile Picture
    34 on at

    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.

  • Suggested answer
    Nya Profile Picture
    29,060 on at

    Hi,

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

    Best Regards,

    Nya

  • Verified answer
    pmrsim Profile Picture
    34 on at

    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.

  • Nya Profile Picture
    29,060 on at

    Hi Pete,

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

     

    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

News and Announcements

Season of Giving Solutions is Here!

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 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 67

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 37 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 24

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans