cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

B2BUnit creation programatically with a nonadmin user

Former Member
0 Kudos
681

Hi,

We have a requirement where B2BUnit and B2B customer details will be captured through Hybris storefront and will be passed to SAP CRM. If the customer and contact person created successfully in CRM then the same has to be created/stored in Hybris as B2BUnit and B2BCustomer. When we are trying to save the B2BUnit details we are getting the error "Only member of an 'admingroup' can create a top level Organization". I think we need to make sure to avoid executing the below logic.

if (ctx.getModelService().isNew(model) && this.getB2bUnitService().getParent(unit) == null && !this.getUserService().isMemberOfGroup(this.getUserService().getCurrentUser(), this.getUserService().getAdminUserGroup())) { throw new InterceptorException( this.getL10NService().getLocalizedString("error.b2bunit.root.create.nonadmin")); }.

Can you please help us in overriding this or any other possible solution to avoid this error programatically?

Thanks and Regards, Sumanth

Accepted Solutions (1)

Accepted Solutions (1)

mansurarisoy
Contributor
0 Kudos

You can check this document about Disabling Interceptors: https://help.hybris.com/6.5.0/hcd/9ce1b60e12714a7dba6ea7e66b4f7acd.html

Former Member
0 Kudos

Thanks Venkateswarlu and Ahmet for your suggestions. it worked.

AnkitGoyal1
Newcomer
0 Kudos
This Link is not working, Can someone please help with the exact steps or new link for the Information.

Answers (1)

Answers (1)

0 Kudos

Hi,

You have to replace the 'B2BUnitModelValidateInterceptor' which is OOTB interceptor. Please follow replace interceptor steps in wiki.

Former Member
0 Kudos

Hi The other way is while saving b2b unit change the user in session context to admin, after change the user to current user which is before b2b unit save. The code sample like this

Thanks

mansurarisoy
Contributor
0 Kudos

For this purpose, I guess sessionService's executeInLocalView() method would be more appropriate.

Ask a Question
Top Q&A Solution Author