Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can you get a custom email using Scriptrunner to import a table correctly? Edited

So I'm attempting to pull the description into the custom email...which is fine, I can pull a jira field without a problem using - ${issue.description}.

The problem is that when a table is in the description, it is imported into the email with deliminators and not the actual table formatting.

How do you get the correct table formatting into the custom email?

Here are some screen shots:

Actual issue description field with table: 

JIRA Description Capture.PNGScriptrunner Preview Custom Email: (using plain text email format)Scriptrunner Custom Email Preview Capture.PNG

Attempted to change the email format to html...but still unsure on how to add html write-up so that the table format is converted correctly.

Help please!

 

2 answers

1 accepted

1 vote
Answer accepted

Hi there, 

The following code will convert the description of issue with key ATG-1 from wiki markup to html

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("ATG-1")
def wikiRenderer = rendererManager.getRendererForType("atlassian-wiki-renderer")
def renderContext = new IssueRenderContext(issue)

def html = wikiRenderer.render(issue.description, renderContext)

Should be easy to use it in your script runner custom email. If you have difficulties in doing it, ping me

Kind regards, Thanos 

Hi Thanos...thank you for the reply.

I copied your script and updated the issue Key with one of mine to test.

Not sure if I'm putting the code in the correct place or not since I'm not seeing a difference in the formatting...see screen shot below.

I've tried adding it in the email template itself but that doesn't work either. The description field is already set for wiki rendering, should I switch this back?

Also...I need it to dynamically pull the information so the Current Issue will be constantly changing. Will the getIssueByCurrentKey("...") dynamically change or will it look for "RMT-330" each time?

Thanks again for your assistance.--Lara

image.png

Thanos,

So I added only "<p><br>${helper.render(issue.description)}" in the email template field and now have columns again...see screen shot. However, I'm still not getting actual uniform table lines...

image.png

Hey there! :D

I've come to clarify some things, as I think I understand the problem that you're having.

The code that Thanos provided needs to be in your "Condition and Configuration" code-block, as you have done. However, in that same code-block you'll want to take the "html" variable and add it to the "config" Map that we provide. By adding it to this Map, you'll be able to access it in the Email template.  After doing that, you'll want to modify the value that you're passing into the "getIssueByCurrentKey" method slightly. Since you want to get the description for the issue being transitioned, you need to pass that method a key for whatever issue is the target of the transition. You can do this by calling the "getKey" method on the "issue" variable that we pass in for you.

FYI: You can see everything that is provided for you by clicking the question mark with a circle around it at the bottom right of the code block. :b

Both of these changes are reflected in an example below:

Screen Shot 2018-10-22 at 4.33.57 PM.png

On top of those two changes, you'll want to make sure that you put a condition in that code-block as well. In my case, I always want the script to run, so I just returned "true" at the very bottom of the script. But you can see more examples for writing a description in our documentation.

Then, once you've made those changes to your code, you'll have access to the "descHTML" variable in the Email template, as shown below:

Screen Shot 2018-10-22 at 4.37.17 PM.png

That should do what you're wanting it to. Try it out and let me know how it goes! :)

Best,
Aidan

Like Justin likes this

Yay! FINALLY. Woo hoo! 

Thank you so much Aidan. Updates made it work. I now see the table :-).

Appreciate all the help!--Lara

 

I had just about the same reaction when I got it working too lol.

Always glad to help out! :D
Aidan

Hi,

 

Can you share code, i'm trying to replicate this scenario?

 

Appreciate your help on this.

 

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

101 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you