# UI Framework Object Structure accessible from Html form

**URL:** <https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021>\
**Category:** Development\
**Tags:** module, developers-forum\
**Created:** [April 18, 2020, 8:00am UTC](https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021 "2020-04-18T08:00:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnbosco](https://talk.openmrs.org/letter_avatar/johnbosco/32/5_5575768a8748004e209b776fc1b2916d.png) [@johnbosco](https://talk.openmrs.org/u/johnbosco)\
**Post date:** [April 18, 2020, 8:00am UTC](https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021/1 "2020-04-18T08:00:50Z")

</div>

I want to implement velocity or logic test in HTML Form like below

```
<excludeIf velocityTest="$patient.gender == 'F' "> Content stays here </excludeIf>

```

Now I want to do something like

```
<excludeIf velocityTest="$user.role == 'Admin' "> Content stays here </excludeIf>

```

How can I acheive this or where can I get the list or structure of the objects, I basically want to show and display form content based on user roles.

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [April 18, 2020, 2:27pm UTC](https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021/2 "2020-04-18T14:27:14Z")

</div>

So for HFE, the gritty work of setting up the Velocity context is done [here](https://github.com/openmrs/openmrs-module-htmlformentry/blob/788b4042411ad43a3e3334a989470214ff39a522/api/src/main/java/org/openmrs/module/htmlformentry/FormEntrySession.java#L159). Might not be the cleanest documentation, but at least it should show you what’s available. As you can see, the Velocity `user` variable refers to the actually authenticated `User` object, which has all the fields listed [here](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/User.java#L46).

To tell if a `User` has a particular role it’s best to use the [`User#hasRole()`](https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/User.java#L126) function as this handles certain logic like nested roles and the idea that the super has all roles. To do this from Velocity, you just need:

```auto
<excludeIf velocityTest="$user.hasRole('Admin')">
    <!-- content goes here -->
</excludeIf>

```

---

<div class="post-metadata">

**Author:** ![johnbosco](https://talk.openmrs.org/letter_avatar/johnbosco/32/5_5575768a8748004e209b776fc1b2916d.png) [@johnbosco](https://talk.openmrs.org/u/johnbosco)\
**Post date:** [April 18, 2020, 3:02pm UTC](https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021/3 "2020-04-18T15:02:51Z")

</div>

This is exactly what am asking for. I will read up the documents. Thanks.

---

<div class="post-metadata">

**Author:** ![elkinleon](https://talk.openmrs.org/user_avatar/talk.openmrs.org/elkinleon/32/8693_2.png) [@elkinleon](https://talk.openmrs.org/u/elkinleon)\
**Post date:** [July 27, 2020, 8:25pm UTC](https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021/4 "2020-07-27T20:25:31Z")

</div>

i want to do the same with the "encounter creator " but encounter.creator doesn’t work

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [July 27, 2020, 8:51pm UTC](https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021/5 "2020-07-27T20:51:56Z")

</div>

I’m going to guess that it’s something like: `$session.encounter.creator`.

---

<div class="post-metadata">

**Author:** ![elkinleon](https://talk.openmrs.org/user_avatar/talk.openmrs.org/elkinleon/32/8693_2.png) [@elkinleon](https://talk.openmrs.org/u/elkinleon)\
**Post date:** [July 28, 2020, 1:44pm UTC](https://talk.openmrs.org/t/ui-framework-object-structure-accessible-from-html-form/28021/6 "2020-07-28T13:44:16Z")

</div>

> [@ibacher](#):
>
> `$session.encounter.creator`

**many many many thank you**.

works perfect with this:

`<includeIf velocityTest="$session.encounter.creator == 'username' ">`
