Sitecore – Slow load times when editing or creating an EXM email

After an upgrade to Sitecore 10.2, I’ve noticed that it took a long time when we create a new EXM message, or when we try to edit a draft. We were looking at the screen with the loading icon for around 2 minutes every time we edit or create an message.

This is because EXM is retrieving the Contact Lists to show in the “Include lists” dropdown in the Recipients tab as shown below:

Within Sitecore < 10, this dropdownlist would only show 10 results, by calling the following url: /sitecore/api/ssc/ListManagement/List?pageSize=10&pageIndex=1&payLoad=full&searchExpression=

Within Sitecore > 10, this dropdownlist shows all results (so all the Contact Lists that are available in the system), by calling the following url:
sitecore/api/ssc/ListManagement/List?payLoad=full&searchExpression=&language=en&pageSize=2147483647

As you can see it’s using Int.MaxValue as PageSize and thus retrieving all records from the system. When you have a lot of Contact Lists this will take some time, as it also retrieves the amount of contacts in those lists.

Unfortunately there’s no easy workaround in code as this is done in Javascript, and there’s no way to recompile the bundle that is used. Luckily we can create a rewrite rule in IIS, that rewrites the url with the max pagesize, to set it to a lower number. An example rewrite rule which will set the pagesize to 10 is as follows:

<rule name="Rewrite ListManager PageSize" patternSyntax="ExactMatch" stopProcessing="true">
    <match url="sitecore/api/ssc/ListManagement/List" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="payLoad=full&amp;searchExpression=&amp;language=en&amp;pageSize=2147483647" />
    </conditions>
    <action type="Rewrite" url="/sitecore/api/ssc/ListManagement/List?payLoad=full&amp;searchExpression=&amp;language=en&amp;pageSize=10" appendQueryString="false" />
</rule>

According to Sitecore this isn’t a bug, and the release notes tell me that this is the “fix” for issue 359727 which was introduced in Sitecore 10.1.

So if you’re running into the same issue, and are not affected by issue 359727, then I’d advise you to implement the rewrite rule that is shown above.

Leave a Reply

Your email address will not be published.