3

My custom rule checks if it is contact's birthday today. Birthdate from Personal facet and current date are compared (respectively their months and days). Following code should do it (at least by my humble guess):

public Expression<Func<Contact, bool>> CreateContactSearchQuery(IContactSearchQueryContext context)
{
    return contact => contact.Personal().Birthdate.HasValue && contact.Personal().Birthdate.Value.Month == DateTime.Now.Month && contact.Personal().Birthdate.Value.Day == DateTime.Now.Day;
}

But as mentioned in the title: YourLinqIsTooStrongException is thrown in logs when I try to do segmented list. See:

Exception: Sitecore.XConnect.Search.YourLinqIsTooStrongException
Message: Unsupported query: (VisitMember): 
Convert([contact].Personal().Birthdate).Month
Source: Sitecore.Xdb.Common.Web at Sitecore.Xdb.Common.Web. Synchronous.SynchronousExtensions.SuspendContextLock[TResult](Func`1 taskFactory) at Sitecore.XConnect.Client.XConnectSynchronousExtensions. SuspendContextLock[TResult](Func`1 taskFactory) at Sitecore.XConnect.Client. XConnectSynchronousExtensions.GetBatchEnumeratorSync[TEntity](IAsyncQueryable`1 asyncQueryable, Int32 defaultBatchSize) at Sitecore.XConnect.Segmentation. SegmentationEngine.<>c.<CountContacts>b__24_0(IAsyncQueryable`1 contacts) at Sitecore.XConnect.Segmentation. SegmentationEngine.PerformSearch[T](IContactSearchQueryFactory queryFactory, Func`2 searchWork, Byte[] syncToken, ContactExpandOptions expandOptions) at Sitecore.XConnect.Segmentation.SegmentationEngine. CountContacts(IContactSearchQueryFactory queryFactory) at Sitecore.Shell.Applications.Analytics.SegmentBuilder. SegmentBuilderForm.GetFilterSectionHtml(XElement filter, Boolean fillVisitorCount) at Sitecore.Shell.Applications.Analytics. SegmentBuilder.SegmentBuilderForm.InitializeFilters() at Sitecore.Shell. Applications.Analytics.SegmentBuilder.SegmentBuilderForm.Initialize(String value)

And the error shown on screen says basically the same: enter image description here

I tried to convert values into string using MMdd format for both but had similar results.

Very similar question has already been asked here: List segmentation on custom rule YourLinqIsTooStrongException error

Difference is that in question already answered there is custom facet, while in my case I only try to access value of Personal facet.

In mentioned question there is advised to just simplify solution for Sitecore predicate engine and also to not forget to register condition in Automation Engine. Which I also did (created new XML file as described here).

So to my question(s) - how should I proceed? Should I simplify the condition somehow more? Is there a way to check that my condition is registered correctly?

Edits: Added clarification when exactly the error is thrown.

2
  • 2
    Try removing the contact.Personal().Birthdate.HasValue part Commented Aug 30, 2018 at 13:44
  • 1
    @JacobNielsen It was actually my original formula of the condition. When this part is removed, same exception is thrown: Exception: Sitecore.XConnect.Search.YourLinqIsTooStrongException Message: Unsupported query: (VisitMember): Convert([contact].Personal().Birthdate).Month
    – Tomas Vana
    Commented Aug 30, 2018 at 13:50

1 Answer 1

5

The real problem with the question/answer linked in the description is the use of custom methods as part of the expression.

This type of exception is normally about types of queries that are not currently supported by XConnect.

The blocking problem on this one is trying to query on properties of a date.

Comparisons with this shape are supported: c.PersonalInformation().DateField > startOfMonth && c.PersonalInformation().DateField < endOfMonth

While queries with this shape don’t: c.PersonalInformation().DateField.Month == month

Unfortunately for something like birthdays, it means your only option is to check the date is within the start and end of the day of the year for all the possible years you allow your users to enter.

That would work, but other alternatives are:

  1. have a separate field/facet with the birthday in the shape you need. This only works if you control what is writing to that facet.
  2. same field/facet as above, but write to it from a XConnect plugin.
3
  • Thanks for the response! Since I'm expecting relatively high load of contacts I will create separate field/facet for this where I will probably store only month and day of contact's birthday. Because checking let's say 100 years back for every contact would be too complex. Thanks again!
    – Tomas Vana
    Commented Aug 31, 2018 at 8:57
  • @TomasVana posted small update, on point 2 I meant same as 1, but using a XConnect plugin.
    – eglasius
    Commented Aug 31, 2018 at 12:04
  • Yea, I understood what you meant but thx for update.
    – Tomas Vana
    Commented Aug 31, 2018 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.