cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Attribute + Personalization Rule - is it possible?

Former Member
0 Kudos

I created a dynamic attribute that represents a Boolean type. I am now trying to create a Personalization rule (SearchRestriction) on that attribute. However, the creation of the SearchRestriction fails - which makes some sense because there is no actual database field.

 Caused by: de.hybris.platform.jalo.flexiblesearch.FlexibleSearchException: cannot search unknown field 'TableField(name='availableToCurrentDistributionChannel',langPK='null',type=QBPVariantProduct)' within type QBPVariantProduct unless you disable checking , infoMap=TypeInfoMap for type = 8796128870482

The error mentions "unless you disable checking". What does "unless you disable checking" mean? Does it refer to something I can do to make this SearchRestriction work? Is what I am am trying to accomplish impossible?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mike,

Search restrictions are appended to your search query. So all attributes used by a search restriction must be mapped to an actual table column. The 'disable checking' talks to overriding the check to fail on unknown fields and is set within a call to the 'search' method. Disabling checking would not allow your query to run, it would just result in a DB error since there isn't a column that represents your dynamic attribute.

-Mark

former_member620692
Active Contributor
0 Kudos

+1 for the explanation of "unless you disable checking"

former_member654797
Discoverer
0 Kudos

Hi, So how do we normally disable checking in such situations. I am getting an error on addressPOS field "search unknown field 'TableField(name='addressPOS',langPK='null',type=EmailAddressRoot)' within type EmailAddressRoot unless you disable checking ". This field got automatically generated when i made ordered="true" in target element. Thanks!

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks guys, this is what I suspected.

FYI, I was able to solve my problem by instead of using a dynamic property, I add an attribute to the user's session. I have access to the session in the search restriction. It look something like this:

 {programOrderOnly} = true AND ?session.DISTRIBUTION_CHANNEL.code = ?session.DC20_CODE
Former Member
0 Kudos

SearchRestrictions (Personalization Rules) are added to the WHERE part of all flexibleSearch queries that selects your target itemtype.

So SearchRestrictions are based on flexibleSearch which is translated to sql for your DB server. Since sql only supports selects on database coulmns its not possible to use dynamic attributs for your search. Dynamic attributes are not stored within the database for sure.

So your problem isn't the support of dynamic attributes for SearchRestrictions but the support for FlexibleSearch.