# Using Property Level UI Permissions with vanilla JavaScript

**URL:** <https://forum.umbraco.com/t/using-property-level-ui-permissions-with-vanilla-javascript/7414>\
**Category:** Questions\
**Tags:** extending, v17\
**Created:** [February 6, 2026, 2:03pm UTC](https://forum.umbraco.com/t/using-property-level-ui-permissions-with-vanilla-javascript/7414 "2026-02-06T14:03:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GunsRoseSS](https://forum.umbraco.com/user_avatar/forum.umbraco.com/gunsrosess/32/2979_2.png) [@GunsRoseSS](https://forum.umbraco.com/u/GunsRoseSS)\
**Post date:** [February 6, 2026, 2:03pm UTC](https://forum.umbraco.com/t/using-property-level-ui-permissions-with-vanilla-javascript/7414/1 "2026-02-06T14:03:39Z")

</div>

Hi all,

I’ve been trying to create a simple extension that hides a property, just like the example in the [documentation](https://docs.umbraco.com/umbraco-cms/customizing/property-level-ui-permissions#write-a-rule-for-a-specific-property). Except: I want to write it in vanilla JavaScript.

I managed to get most of it working myself. I started off with an umbraco-package.json:  
`{`  
`“$schema”: “../../umbraco-package-schema.json”,`  
`“name”: “Project.Backoffice”,`  
`“version”: “1.0.0”,`  
`“extensions”: [`  
`{`  
`“type”: “workspaceContext”,`  
`“alias”: “Project.Backoffice.WorkspaceContext”,`  
`“name”: “Project Backoffice Workspace context”,`  
`“api”: “/App_Plugins/Project.Backoffice/workspace-context.js”,`  
`“conditions”: [`  
`{`  
`“alias”: “Umb.Condition.WorkspaceAlias”,`  
`“match”: “Umb.Workspace.Document”`  
`}`  
`]`  
`}`  
`]`  
`}`

And a worspace context file:

```auto
import { UmbControllerBase } from “@umbraco-cms/backoffice/class-api”;
import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from “@umbraco-cms/backoffice/document”;

export class MyDocumentPropertyPermissionWorkspaceContext extends UmbControllerBase {
constructor(host) {
super(host);

    // Consume the document workspace context
    this.consumeContext(
        UMB_DOCUMENT_WORKSPACE_CONTEXT,
        (context) => {
            console.log(context);

            this.observe(context?.structure.propertyStructureByAlias('headerImage'), (property) => {
                console.log(property);

                // Create a guard rule:
                const rule = {
                    unique: 'hideHeaderImage',
                    permitted: false,
                    message: "The property is not writable because of my custom restriction.",
                    propertyType: {
                        unique: property.unique
                    }
                }
                // Add the rule to the write guard
                context.propertyWriteGuard.addRule(rule)
            });
        }
    );
}

}

export { MyDocumentPropertyPermissionWorkspaceContext as api };

```

The first console.log works fine and returns a context. However, I get an error within the observer:

 ![image](https://forum.umbraco.com/uploads/default/original/2X/4/4cb1a263f49cca1e11aa045532d4c600f8b1105d.png)

I’m using Umbraco 17.1.0. Has anyone tried this before? Bonus points if you know how to fetch all the properties of a certain tab of the current page. 🙂

Cheers,

Richard

---

<div class="post-metadata">

**Author:** ![mistyn8](https://forum.umbraco.com/user_avatar/forum.umbraco.com/mistyn8/32/671_2.png) [@mistyn8](https://forum.umbraco.com/u/mistyn8)\
**Post date:** [February 6, 2026, 3:07pm UTC](https://forum.umbraco.com/t/using-property-level-ui-permissions-with-vanilla-javascript/7414/2 "2026-02-06T15:07:45Z")

</div>

[Conditional Displayers | Umbraco Marketplace](https://marketplace.umbraco.com/package/our.umbraco.conditionaldisplayers)

maybe some pointers here.. the docs suggest extended features.. but not sure is that’s in v17…

> ## Tabs and Groups
> 
> The previous documentation talks about _property names_ to configure the editors, but you can also configure them to show or hide tabs and groups. [Jump to the extended documentation.](https://github.com/skartknet/ConditionalDisplayers/blob/main/Documentation/tabs-and-groups)

most `uui-components` have a `readonly` parameter, that could be of use too?

---

<div class="post-metadata">

**Author:** ![nielslyngsoe](https://forum.umbraco.com/user_avatar/forum.umbraco.com/nielslyngsoe/32/610_2.png) [@nielslyngsoe](https://forum.umbraco.com/u/nielslyngsoe)\
**Post date:** [February 6, 2026, 4:04pm UTC](https://forum.umbraco.com/t/using-property-level-ui-permissions-with-vanilla-javascript/7414/3 "2026-02-06T16:04:42Z")

</div>

Sadly a problem that I think would have been discovered if you had used TypeScript.

it does not need to be complicated to use TypeScript, but it does require that you run a build script, and under development you would like a Watch script so you do not need to run it again and again.

Anyway, I feel pretty sure that `context?.structure.propertyStructureByAlias` return a promise, aka is an async method. So you need to put `await` in front of that call.

To be able to do that you need to make the surrounding method async, put `async` in front of `(context) => {` so it becomes `async (context) => {`

(Update: I corrected the Docs article as well. I see your code properly originated from it. Sorry for that trouble, but good that it is corrected now.)

The rest looks about right, Good luck

---

<div class="post-metadata">

**Author:** ![GunsRoseSS](https://forum.umbraco.com/user_avatar/forum.umbraco.com/gunsrosess/32/2979_2.png) [@GunsRoseSS](https://forum.umbraco.com/u/GunsRoseSS)\
**Post date:** [February 9, 2026, 8:07am UTC](https://forum.umbraco.com/t/using-property-level-ui-permissions-with-vanilla-javascript/7414/4 "2026-02-09T08:07:46Z")

</div>

Thanks, I’ll give it a read 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.umbraco.com/uploads/default/original/1X/624adeddd330a3d0268a184db47946ca7e82c676.png) [@system](https://forum.umbraco.com/u/system)\
**Post date:** [March 11, 2026, 8:08am UTC](https://forum.umbraco.com/t/using-property-level-ui-permissions-with-vanilla-javascript/7414/5 "2026-03-11T08:08:42Z")

</div>

Closed on March 11, 2026, 8:08am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
