In this scenario, we will allow portal users to download documents for support cases related to their company from any document location in the CRM. Additionally, portal users who are the primary contact for the support case may upload and delete documents. The content will be placed using the "script" option to allow it to be placed within an entity form.
Create another SharePoint Permission record for cases, with Customer Visibility and the Allow Download permission. Under Customer Visibility Properties, set Customer Field Name to "primarycontactid": This will restrict access to the selected permissions to portal users whose contactid value equals the case's primarycontactid value.
The result will a list of uploaded files for the support case, with the ability to specify which one of multiple document locations you wish to view. The primary contact for the case will be able to upload and delete documents:
However, other contacts belonging to the support case's parent account will only be able to view and download: