Trying to hide a webpart based on document category

Plaid Enterprises asked on February 10, 2022 20:09

I have a webpart on a page template that I want to hide if a document is in a particular category. I know how to make a webpart visible based on the document category, but how can I hide it? Is there a way to negate {% CurrentDocument.IsInCategories("CategoryZ") #%} macro?

Correct Answer

Liam Goldfinch answered on February 11, 2022 01:01

Maybe you could try:

{% CurrentDocument.IsInCategories("CategoryZ") == false #%}

or

{% !CurrentDocument.IsInCategories("CategoryZ") #%} 
0 votesVote for this answer Unmark Correct answer

Recent Answers


vasu yerramsetti answered on February 11, 2022 02:18

Each web part have visible property. So you can use above macro and follow below steps:

  1. Go to Web part properties
  2. Click arrow symbol at Visible property to open Edit Value popup to add Macros
  3. Add your macro here
  4. Save and check result on web page

Refer attached screenshot for detailed - https://paste.pics/8016290f6714559f38cc522b86e6310c

0 votesVote for this answer Mark as a Correct answer

Plaid Enterprises answered on February 11, 2022 16:05

Thanks, guys! Liam's first suggestion worked perfectly!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.