How to get rid of the warning in the Condition & Config script for custom email post function

Lara Arthur February 8, 2021

Hi there Atlassian Community...

A few years back I had used the following in the 'Condition and Configuration' field to send a custom email (Jira v8.5.1 and SR v5.6.13.1-p5):

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.RendererManager
import com.atlassian.jira.issue.fields.renderer.IssueRenderContext
import com.atlassian.jira.issue.fields.renderer.JiraRendererPlugin

def rendererManager = ComponentAccessor.getComponent(RendererManager)
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey(issue.key)
def wikiRenderer = rendererManager.getRendererForType("atlassian-wiki-renderer")
def renderContext = new IssueRenderContext(issue)

config.deschHTML = wikiRenderer.render(issue.description, renderContext)
return true

I'm now attempting on creating a custom email using the info I had before, and am getting a warning on the def issue line.

"Variable "issue" masks a binding variable of the same name. Please choose a different name for variable: "issue" @[deleted] 11, column 5."

Does anyone know what this should be and/or why this isn't working any longer? I've tried making several updates based on things I was able to find in the community, but nothing is working.

Currently running most recent versions of both Jira and ScriptRunner.

Thanks--Lara

1 answer

0 votes
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 8, 2021

Hi @Lara Arthur 

In your post function you already have issue as a binding variable. So try the post function again by commenting that line.

Ravi

Lara Arthur February 9, 2021

Hi @Ravi Sagar _Sparxsys_ not sure I am following. Can you provide additional details? Thanks --Lara

Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 9, 2021

Comment this line in your code.

def issue = ComponentAccessor.issueManager.getIssueByCurrentKey(issue.key)
Lara Arthur February 10, 2021

@Ravi Sagar _Sparxsys_ sorry, still not following. This is how the email post function is set up ....I've placed the line in the only spot it can go. This was working on an earlier version (I used the exact same format)...but it's not working now and giving me a warning. Email Post function.JPG

When I try and run it to preview, I get this:

Email post function error.JPG

Suggest an answer

Log in or Sign up to answer