Issue:
javax.servlet.ServletException: com.ibm.commerce.exception.ECApplicationException: The user does not have the authority to run this command "com.ibm.commerce.user.beans.OrganizationDataBean".
How to Replicate:
There could be several scenarios to replicate this. This is one scenario to replicate.
- Register user to an organization say Organization X.
- In Organization console give privileges to user as buyer for organization Y.
- Now log on to your storefront and change the role of user with which he is buying the products ( In this case Organization Y). This step may not be present for all the sites. Point to note is User has to place an order as buyer for organization Y.
- Now in any of the jsp/class try to access OrganizationDataBean by using the organization user registered with ( In this example: Organization X)
I was using this below code
UserRegistrationDataBean buyurdb=new UserRegistrationDataBean();
buyurdb.setUserId(requisitionerId);
com.ibm.commerce.beans.DataBeanManager.activate(buyurdb, request);
OrganizationDataBean buyorgdb = new OrganizationDataBean();
buyorgdb.setInitKey_MemberId(buyurdb.getOrganizationId());
com.ibm.commerce.beans.DataBeanManager.activate(buyorgdb, request);
Cause:
If you notice USERREG table has the data stating this user is registered to Organization X, But not the role with which he is buying in the storefront.
Fix:
My objective was to get the organization information with which user placed the order. When user place the order , organization id will be stored in ORDERS table. Get the organization id from ORDERS table instead of UserRegistationDataBean.
OrganizationDataBean buyorgdb = new OrganizationDataBean();
buyorgdb.setInitKey_MemberId(buyurdb.getOrganizationId()); --Member id has to get from ORDERS table
com.ibm.commerce.beans.DataBeanManager.activate(buyorgdb, request);
No comments:
Post a Comment