JSON Formatting View to hide commandbarprops based on user

Mcintosh, Rebecca 226 Reputation points
2026-07-07T13:48:59.6633333+00:00

Hello!

Can someone please help with the syntax for this please? I am hoping to hide the delete button within a SharePoint view depending on whether the logged in user is the same as the Created By user. I've started with this but is not working but I'm hoping it's just I've got the syntax wrong rather than it's not possible! I tried [@Me] as well but this didn't work either.

{
        "key": "delete",
        "hide": "=if([$CreatedBy] == [Me],false, true)"
      }
Microsoft 365 and Office | SharePoint | Development
0 comments No comments

Answer accepted by question author

Michelle-N 19,260 Reputation points Microsoft External Staff Moderator
2026-07-07T14:58:01.6966667+00:00

Hi @Mcintosh, Rebecca

Based on your description, I understand you are trying to use SharePoint JSON View/Command Bar formatting to conditionally hide the Delete button. You want it to remain visible only if the currently logged-in user is the same person who created the item (Created By), but your current formula (=if([$CreatedBy] == [Me],false, true)) isn't registering correctly.

You are actually very close! It is completely possible to achieve this, but there are two specific syntax constraints in SharePoint JSON formatting that are causing your current code to fail:

Neither [Me] nor [@Me] are valid tokens in SharePoint JSON. The correct lowercase token is @me. You cannot compare the current user directly to the entire Created By person object. Instead, you must extract a specific text string from it, such as the email address, using its internal system column name, which is Author. Therefore, you need to use [$Author.email].

To hide the delete button for everyone except the creator, you need to wrap your command customizer inside the commandBarProps schema structure.

Here is the correct, working JSON code you can copy and paste directly into your View Formatting settings:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "commandBarProps": {
    "commands": [
      {
        "key": "delete",
        "selectionModes": ["SingleSelection"],
        "hide": "=if(@me == [$Author.email], false, true)"      },
      {
        "key": "delete",
        "selectionModes": ["MultiSelection"],
        "hide": true      }
    ]
  }
}

[Me] or [@Me] is not the correct token here. Use @me, and don’t compare the whole Created By person object directly. Compare the user’s email instead: [$Author.email]. The expression above means: if the current user is the Created By user, show Delete; otherwise hide it. Microsoft’s syntax reference shows Excel-style expressions starting with = and includes an example using @me != [$Author.em

Also, this is only a UI customization, not a security control. View formatting changes how items or commands are displayed, but it does not change the underlying list data or permissions. If users must not be able to delete other users’ items, enforce that with SharePoint permissions/item-level permissions or a governance process instead.
Please refer the following documents:

Formatting syntax reference

Use view formatting to customize SharePoint

I hope this information help.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click ""Comment"".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.