forcedotcom / forcedotcom/b2b-commerce-on-lightning-quickstart
Unable to use B2BSearchControllerSample.productSearch with effectiveAccountId and Named Principal Named Credential so unable to display prices
- Dominant language
- Shell
- Stars
- 191
- Forks
- 211
- PR merge metrics
- No merged PRs in 30d
Description
We’ve run into an issue with the reference component that uses the REST Connect API for searching that we need to use for a custom Category / Search Results.
B2BSearchControllerSample.productSearch:
https://github.com/forcedotcom/b2b-commerce-on-lightning-quickstart/blob/b8a34565d394a2b4460cee0bc587b2c720e87842/examples/lwc/force-app/main/default/classes/B2BSearchControllerSample.cls#L24
That calls the product-search endpoint.
httpRequest.setEndpoint(
'callout:CallMeBack/services/data/v' +
apiVersionApexClass +
'/commerce/webstores/' +
webstoreId +
'/search/product-search'
);
The reference implementation ignores the effectiveAccountId (note it is a parameter to the Apex method, but never passed in the REST call), which means that pricing is not displayed. When we add it as specified in the documentation https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_commerce_webstore_product_search.htm
?effectiveAccountId=
We get an error:
`[{"errorCode":"INVALID_API_INPUT","message":"Only a buyer user can access this account."}]`
We followed the setup steps here for the Named Credential:
https://github.com/forcedotcom/b2b-commerce-on-lightning-quickstart/blob/master/examples/lwc/docs/NamedCredentials.md
The problem is that our Named Principal doesn’t have the Buyer User system permission. So, we created a permission set to assign it to our Named Principal user, but it is not possible. We get an error that the Buyer User permission is not applicable for the license type of our Named Principal, which is Salesforce (also doesn’t work for Platform). However, there is no way to create a named principal for the Named Credential that is a Community Login User and we cannot do it on a Per User basis either, because that would require the store users to go through the webflow for oauth which we obviously cannot do.
We are stuck on not being able to use this AND display pricing.
Ideally, the reference implementation should be updated to not ignore the effectiveAccountId parameter since it is more likely that prices would be desired in the search results than not. At least, if it is not possible, that should be documented.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with B2BSearchControllerSample.cls, especially productSearch and its product-search endpoint call, then review docs/NamedCredentials.md and the linked product-search API documentation. Determine whether effectiveAccountId and pricing can be supported with the described Named Principal setup; done means the reference behavior is corrected or the limitation is documented.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100