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

B2BUnit creation programatically with a nonadmin user

Former Member
0 Kudos
693

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

View Entire Topic
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.