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?

Accepted Solutions (1)

Accepted Solutions (1)

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

Answers (1)

Answers (1)

0 Kudos

Hi Juan,

In your example, shippingAddress is just a reference, not a collection or relation. So I do not see any reason why referenceSearchCondition shouldn't work.

referenceSearchCondition_owner and passing the {parentObject} should do. I even did a quick test on 5.7 my changing the configuration for Company and it worked as expected(only addresses of the Company were shown).

0 Kudos

Hi Shamugaraja, thank you for double checking that.
Unfortunately that doesn't work for me. I am on 6.3 . I believe the reason is that on 5.7 User.addresses is an attribute of Users and on 6.3 it is part of a (conditional) reference.

I guess that is a bug. Hopefully someone has a workaround or Hybris fixes that on 6.x any time soon.

Kind regards,
Carlos

0 Kudos

Hi Carlos, am confused now. isn't your example config is about Company.shippingAddress?? This attribute definition hasn't changed even in 6.3.

0 Kudos

Hi Shamugaraja:

My example is about B2BUnit which has Company, UserGroup and User up in its hierarchy. The idea is filtering the Address reference editor of B2BUnit.shippingAddress (or B2BUnit.billingAddres, or others) so that it contains only addresses of the particular B2BUnit.

In 6.3 there is a relation User2Addresses (which applies to B2BUnit to Addresses), hence the condition above will result internally in a Relation Condition (seen while debugging).
In 5.7 there is no such relation.

Regards,
Carlos