cancel
Showing results for 
Search instead for 
Did you mean: 

referenceSearchCondition on relations

0 Kudos

Due to not yet implemented functionality in Backoffice, B2BUnit.billingAddress (and other Address references) doesn't filter billing addresses of the particular B2BUnit. Instead it will offer to select from all available addresses in the system.
https://answers.sap.com/questions/12762488/isselectionof-in-backoffice.html

As a workaround, I was trying to filter the reference editor to select only the Addresses where the current B2BUnit is the owner.
For that, I would use set the referenceSearchCondition property to the editor. Something like this:

 <context merge-by="type" parent="UserGroup" type="Company" component="editor-area" module="mybackofficeextension">
     <editorArea:editorArea xmlns:editorArea="..." name="">
         <editorArea:tab name="hmc.addresses" position="2" merge-mode="replace">
             <editorArea:section name="hmc.addresses">
                 <editorArea:attribute qualifier="shippingAddress" editor="com.hybris.cockpitng.editor.defaultreferenceeditor">
                     <editorArea:editor-parameter>
                         <editorArea:name>referenceSearchCondition_owner</editorArea:name>
                         <editorArea:value>{parentObject}</editorArea:value>
                     </editorArea:editor-parameter>
                 </editorArea:attribute>
             </editorArea:section>
         </editorArea:tab>
     </editorArea:editorArea>
 </context>

But that results in an java.lang.IllegalArgumentException: GenericSubQueryCondition is only compatible with following operators: [IN, NOT_IN, EXISTS, NOT_EXISTS] error.

I have also tried with referenceSearchCondition_owner_in but then I get java.lang.IllegalStateException: Unsupported operator IN for references.

Any idea on how to make that referenceeditor list only addresses of the B2BUnit?

View Entire Topic
0 Kudos

Hi Carlos,

I understand. It seems to fail while creating a subQuery(due to the relation that seems to have been introduced newly). Of course if you try to use IN, EXIST, etc, it will fail while creating the main query itself as it is querying for a reference. I would say this is something for hybris to fix. Probably there is a 'workaround', but I am not aware of any.

What you can do is,

 <editorArea:attribute qualifier="shippingAddress">
      <editorArea:editor-parameter>
          <editorArea:name>availableValuesProvider</editorArea:name>
                          <editorArea:value>myValueProviderBean</editorArea:value>
                      </editorArea:editor-parameter>
         <editorArea:name>referenceSearchCondition_owner</editorArea:name>
                          <editorArea:value>{parentObject}</editorArea:value>
                      </editorArea:editor-parameter>
 </editorArea:attribute>

myValueProviderBean = Customer Implementation of ReferenceEditorSearchFacade. here you can return only the applicable Addresses as Pageable

You still need the referenceCondition, because you need to pass the B2BUnit that needs to be checked.

Hope this helps.

Best

Shanmugaraja