Context values in Module Condition

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/
[2] https://developer.atlassian.com/cloud/jira/service-desk/jira-expressions-type-reference/#customerrequest

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. 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.

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:

{
    "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/

But that yielded:

"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 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?

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

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

So to get the request type ID, write:

customerRequest.requestType.id

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

"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

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 to the webhook URL, but the customerRequest expression property is null.

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.

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

        "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

Looks like it. I suggest creating a ticket in the JSDECO project to make the context more useful in that location.