We're on SharePoint online, and user profiles are synced to SharePoint.

I have a number of libraries that I want users to be able to search, but I want to restrict the documents that specific departments (Sales) can see to those that they have modified, created (author), or are identified in People type fields. For any users outside of those specific departments, I want it to be the full search.

I have the user section working properly (current user is associated to the record), but I am having trouble filtering the whole search based on the current user's department.

Re-creating the library or manually setting permissions aren't options at this point due to size (<900k documents) and business restrictions (actively being used in production), so I'm limited to constraining via search right now.

Any/all help is welcome! My search results query is below.

      ListID:{removed for security} OR ListID:{removed for security} OR ListID:{removed for security}
          {User.Department}="Commercial Sales - Healthcare"
            OR {User.Department}="Commercial Sales"
            OR {User.Department}="Commercial Sales - Enterprise"
            OR {User.Department}="Federal Sales - Healthcare"
            OR {User.Department}="Federal Sales - Civilian"
            OR {User.Department}="Federal Sales - DOD"
            OR {User.Department}="SLED Sales"
        ) AND (
          OR ModifiedBy={User.Name}
          OR ISAM={User.Name}
          OR Salesperson={User.Name}
      ) OR (
          {User.Department}<>"Commercial Sales - Healthcare"
            AND {User.Department}<>"Commercial Sales"
            AND {User.Department}<>"Commercial Sales - Enterprise"
            AND {User.Department}<>"Federal Sales - Healthcare"
            AND {User.Department}<>"Federal Sales - Civilian"
            AND {User.Department}<>"Federal Sales - DOD"
            AND {User.Department}<>"SLED Sales"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.