Forum Discussion
Best practices for making Add-in available for limited number of site collections
Hi,
We had the same need and had the same problem. So applied one dirty workaround which is
- Installed and deployed (tenant scope) the provider hosted add-in in app catalog for team site template. We deployed at tenant scope because we wanted that add-in available by default in new site collections so that user does not have to install it but limited to team site collection template.
- in site creation process, set one property in web property bag to SiteType X for e.g. in your case property value could be LoB
- in same site creation process, embed JS (JS injection through custom action) which will read the property value and if property value = LoB, then it will show the add-in on site contents page otherwise by default this add-in will be hidden
- in Romote web code of add-in, we have implemented the logic so that in case by some reason user is able to reach the add-in URL with proper token in a site collection where it should be hidden, which will check the site property bag again before loading the default page of the add-in. If property value is not set to LoB, it will show the error page.
Since it was critical for us to implement this, so this was the quick workaround which was implemented.
- Prashant.