This repo contains a service class that can be used to mirror Opportunity shares granted both on the opportunity and the opportunity's parent account to the quote.
This should be used in situations where you would like a quote to get its shares from the opportunity as it would through a master-detail relationship with the opportunity.
-
Make sure that the account, opportunity, and quote access is set to private or read only
-
Call the
CPQ_QuoteShareService
from your triggers, batch jobs, etc.
CPQ_QuoteShareService.syncQuoteAccessFromAccountAndOpportunity(quoteList); //where quoteList is a list of quotes
- Update the test class to make sure that it passes in your org
- This should be implemented in triggers very sparingly. Calling it from any trigger except the quote will put you at risk of hitting governor limits.
- Consider creating a scheduled batch job to call this code so that sharing is recalculated for quotes in a specific criteria. The code only creates or deletes shares if the change is required, so you should not have to worry about locking quotes while people are working on them or other unnecessary database activity.
- Test this a lot before using it in production
First, make sure that all of the npm modules are installed
npm install
Then, you can make a scratch org with CPQ installed using the following command:
npm run crate:scratch