cancel
Showing results for 
Search instead for 
Did you mean: 

Need to escape custom session parameters importing SearchRestrictions by impex?

0 Kudos
510

Hi all, on Hybris 6.4 (5.7 as well) we're trying to import a SearchRestriction using Impex, to create a custom restriction on a dedicated user setted as sessionUser on a products sync job (in 5.7, I knew, was the only way to apply restrictions on sync jobs) to just sync some specific products. The restriction query is something like:

EXISTS ({{ SELECT DISTINCT {p.pk} FROM { Product AS p } WHERE {p.pk}={item.pk} AND {p.customAttribute} in ( ?session.currentCronJob.customAttributeList ) }})

customAttributeList is a custom field setted in a custom sync Cronjob instance (list of strings). customAttribute is a string identifying a custom parameter.

During impex import using hac (but using project data too), we have the following error: Exception : line 2: cannot create SearchRestriction with values ItemAttributeMap[...] due to no attribute ImpExImportJob.customAttributeList found transaction rolled back because it has been marked as rollback-only

It seems that during impex import, the query is evaluated trying to replace parameters with valid plain (current session) values. Is this the correct behaviour? Shouldn't the query not to be evaluated during import?

Now questions are: How can we successfully import this kind of SearchRestriction using impex? Has any option which let us configure impex engine to not evaluate query parameters during impex import? Any other option to escape parameters during import?

Ref. https://help.hybris.com/6.4.0/hcd/8c428f8286691014970ceee87aa01605.html#restrictions-creatingrestric... https://help.hybris.com/6.4.0/hcd/8b9ce4868669101499b2f0f25ef9395f.html#cronjob-technicalguide-using...

View Entire Topic
0 Kudos

The problem occurs when parameters "session.currentJob" or "session.currentCronJob" are used, Please, just for test, are you able to import this impex?

 INSERT_UPDATE User ; uid[unique=true] ; name[en]
 ; testUser; testUser
 
 INSERT_UPDATE SearchRestriction ; code[unique=true] ; name[lang=de] ; name[lang=en] ; principal(UID) ; restrictedType(code) ; active ; generate ; query                         ; test ; test ; test ;  testUser ; Product  ; false  ; false    ; "EXISTS ({{ SELECT DISTINCT {p.pk} FROM { Product AS p } WHERE {p.pk}={item.pk} AND {p.customAttribute} in ( ?session.currentCronJob.customAttributeList ) }})"

Do you receive my same error?