# Context values in Module Condition

**URL:** <https://community.developer.atlassian.com/t/context-values-in-module-condition/33583>\
**Category:** Jira Cloud\
**Tags:** jira-expressions, jira-cloud\
**Created:** [November 19, 2019, 12:51am UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583 "2019-11-19T00:51:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.gunter](https://avatars.discourse-cdn.com/v4/letter/d/5f8ce5/32.png) [@david.gunter](https://community.developer.atlassian.com/u/david.gunter)\
**Post date:** [November 19, 2019, 12:51am UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/1 "2019-11-19T00:51:32Z")

</div>

Is there any way to get all the context values used and evaluated by Jira when loading a module?

I’m trying to have a module only display for certain request types using Jira Expressions + Conditions[1][2].

I’ve been unable to use the `customerRequest.requestType.id` context value, and I suspect it’s because the context value isn’t set at all.

[1] [https://developer.atlassian.com/cloud/jira/platform/conditions/](https://developer.atlassian.com/cloud/jira/platform/conditions/)  
[2] [https://developer.atlassian.com/cloud/jira/service-desk/jira-expressions-type-reference/#customerrequest](https://developer.atlassian.com/cloud/jira/service-desk/jira-expressions-type-reference/#customerrequest)

---

<div class="post-metadata">

**Author:** ![kkercz](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/kkercz/32/37626_2.png) [@kkercz](https://community.developer.atlassian.com/u/kkercz)\
**Post date:** [November 19, 2019, 7:53am UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/2 "2019-11-19T07:53:18Z")

</div>

You can debug Jira expressions used in web conditions with webhooks, see here for details: [https://developer.atlassian.com/cloud/jira/platform/jira-expressions/#monitoring](https://developer.atlassian.com/cloud/jira/platform/jira-expressions/#monitoring). This should allow you to figure out what’s going on.

The `customerRequest` context variable might not be available on pages that aren’t inherently Service Desk.

---

<div class="post-metadata">

**Author:** ![david.gunter](https://avatars.discourse-cdn.com/v4/letter/d/5f8ce5/32.png) [@david.gunter](https://community.developer.atlassian.com/u/david.gunter)\
**Post date:** [November 21, 2019, 12:15am UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/3 "2019-11-21T00:15:35Z")

</div>

Thanks for info @kkercz! Was able to run some debug tests using a Service Desk instance.

On the “Create Request” page I tried this module condition:

```auto
{
    "condition": "jira_expression",
            "params": {
               "expression": "serviceDesk.id == 2 && serviceDesk.requestTypeId == 38"
       }
 }

```

based on this page’s context params: [https://developer.atlassian.com/cloud/jira/platform/context-parameters/](https://developer.atlassian.com/cloud/jira/platform/context-parameters/)

But that yielded:

```auto
"Evaluation failed: \"serviceDesk.requestTypeId\" - Unrecognized property of `serviceDesk`: \"requestTypeId\" ('requestTypeId'). Available properties of type 'ServiceDesk' are: 'id', 'project'" 

```

I also tried  
`"serviceDesk.id == 2 && customerRequest.requestType.id == 38"`  
and  
`"serviceDesk.id == 2 && requestType.id == 38"`

Which both did not yield the expected result of “only display iframe in project (1) for requestType id (38)”

Interestingly enough, the [App Connect docs](https://developer.atlassian.com/cloud/jira/platform/context-parameters/) say this about servicedesk context params:

> `servicedesk.requestTypeId` for ‘Create request view’ and ‘Request details view’

It seems like the URL context params are populated different than the values evaluated in the module condition block.

Am I out of luck trying to restrict a “Request Create Entity Property Panel” to a specific issue type?

---

<div class="post-metadata">

**Author:** ![kkercz](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/kkercz/32/37626_2.png) [@kkercz](https://community.developer.atlassian.com/u/kkercz)\
**Post date:** [November 21, 2019, 7:02am UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/4 "2019-11-21T07:02:43Z")

</div>

The `ServiceDesk` type doesn’t have the `requestTypeId` property in Jira expressions, see its documentation here: [https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference/#servicedesk](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference/#servicedesk)

To get a hold of the request type, you can use the `customerRequest` context variable. All context variables available for the web condition expression are documented here: [https://developer.atlassian.com/cloud/jira/platform/conditions/#jira-expression-condition](https://developer.atlassian.com/cloud/jira/platform/conditions/#jira-expression-condition)

So to get the request type ID, write:

```auto
customerRequest.requestType.id

```

---

<div class="post-metadata">

**Author:** ![david.gunter](https://avatars.discourse-cdn.com/v4/letter/d/5f8ce5/32.png) [@david.gunter](https://community.developer.atlassian.com/u/david.gunter)\
**Post date:** [November 22, 2019, 11:23pm UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/5 "2019-11-22T23:23:25Z")

</div>

Thanks again @kkercz! It looks like customerRequest is `null` when accessing the “Create Request” service desk page:

```auto
"Evaluation failed: \"customerRequest.fakeTestProperty\" - Unrecognized property of `customerRequest`: \"fakeTestProperty\" ('fakeTestProperty'). Type null does not have any properties"

```

Here’s the exact module I’m applying the condition to: [Request create property panel](https://developer.atlassian.com/cloud/jira/service-desk/request-create-property-panel/)

Going back to my earlier question: it looks like there’s some inconsistency in what values are available to the expression evaluator and the webhooks. I can send the [requestTypeId](https://developer.atlassian.com/cloud/jira/platform/context-parameters/) to the webhook URL, but the customerRequest expression property is null.

---

<div class="post-metadata">

**Author:** ![kkercz](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/kkercz/32/37626_2.png) [@kkercz](https://community.developer.atlassian.com/u/kkercz)\
**Post date:** [November 25, 2019, 8:37am UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/6 "2019-11-25T08:37:26Z")

</div>

Indeed, variables available in webhook URLs are different to context variables available in expressions. It’s a different mechanism.

If `customerRequest` is not available in your context, you can still get the issue type directly from the issue: `issue.issueType.id`. As far as I know, customer request types are directly mapped to issue types anyway.

---

<div class="post-metadata">

**Author:** ![david.gunter](https://avatars.discourse-cdn.com/v4/letter/d/5f8ce5/32.png) [@david.gunter](https://community.developer.atlassian.com/u/david.gunter)\
**Post date:** [November 25, 2019, 10:46pm UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/7 "2019-11-25T22:46:24Z")

</div>

Hm. Even the `issue` context is not available. I’m seeing this context returned by the error monitor:

```auto
        "expression": "serviceDesk.id == 1 && issue.issueType.id == 10008",
        "errorMessages": [
            "Evaluation failed: \"issue.issueType\" - Unrecognized property of `issue`: \"issueType\" ('issueType'). Type null does not have any properties"
        ],
.... irrelevant data ....
        "context": {
            "serviceDesk": {
                "id": "1",
                "projectId": "10000",
                "projectName": "Access Requests",
                "projectKey": "AR",
                "_links": {
                    "self": "https://{tenant}.atlassian.net/rest/servicedeskapi/servicedesk/1"
                }
            },
            "project": {
                "self": "https://{tenant}.atlassian.net/rest/api/2/project/10000",
                "id": "10000",
                "key": "AR",
                "assigneeType": "PROJECT_LEAD",
                "name": "Access Requests",
                "roles": {},
                "avatarUrls": { .. removed for brevity ... },
                "projectTypeKey": "service_desk",
                "simplified": false,
                "style": "classic",
                "properties": {}
            }
        }

```

Appears that the context available to `requestCreatePropertyPanel` is too limited to actually evaluate any conditionals beyond “only display for this project.”

@kkercz

---

<div class="post-metadata">

**Author:** ![kkercz](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/kkercz/32/37626_2.png) [@kkercz](https://community.developer.atlassian.com/u/kkercz)\
**Post date:** [November 26, 2019, 6:25am UTC](https://community.developer.atlassian.com/t/context-values-in-module-condition/33583/8 "2019-11-26T06:25:54Z")

</div>

Looks like it. I suggest creating a ticket in the [JSDECO](https://ecosystem.atlassian.net/browse/JSDECO) project to make the context more useful in that location.
