The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
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:
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.