cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pmrsim
Regular Visitor

D365 CRM Portal Error on Loading Entity Form Server Error

Hello,

 

first time posting, sorry it's with a problem/question!

 

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. Yay.

 

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.

Through research I have found that the important part of the error message is this:

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

...and it seems I need to find a way to change "SingleOrDefault" to "FirstOrDefault", however I do not know where or how to do that. 

 

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

The full error message:

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

 

 

Any help would be much appreciated. Thank you!!

Pete.

 

(ps. cross-post https://community.dynamics.com/365/f/dynamics-365-general-forum/424351/d365-crm-portal-error-on-load...)

1 ACCEPTED SOLUTION

Accepted Solutions
pmrsim
Regular Visitor

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: https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/entity-forms#basic-form-attribute...

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.

View solution in original post

3 REPLIES 3
MarkBiggerstaf
Microsoft
Microsoft

Hello,

 

After reviewing the previous thread and the description of your issue, you will likely need to open a formal support ticket for troubleshooting.

 

You could try creating a new entity list and form on a test page with no customizations.  If that works, you might be able to compared the two to find the differences.

https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/entity-lists

 

If you are still unsuccessful, my recommendation is opening a new support ticket and the next available engineer will be assigned.

 

Thanks,

 

Mark Biggerstaff

Dynamics Support

Thanks for the suggestion Mark.

How do I log a ticket though... I seem to be hitting brick walls whichever way I try.., as I'm not a 'partner'.

 

Edit: Nevermind, I have logged a ticket with MS.

 

Thanks,

Pete.

pmrsim
Regular Visitor

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: https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/entity-forms#basic-form-attribute...

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.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,901)