Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Description(HTML) based on issue type

Nikhil June 21, 2019

I am trying to set default description based on the issue type chosen, But the default value is in HTML. I have a very basic knowledge in scripting. Can anyone help me or provide me with some documentation which can sever my need would do a great help.

Behavior Script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
Issue issue = issue
//def issue = issue as MutableIssue
if(issue.getIssueType.toString().equals("story")){
issue.setDescription("")}
{color:#654982}*Pull Requests & Branches*{color}
 <Devs to copy a link to at least the main PR on GitHub for ease>

{color:#654982}*Contacts*{color}
 <delete or add to below as appropriate>
||PO||UI Designer||Analytics||Optimisation||
|Col A1|Col A2| | |

 {color:#654982}*User Stories*{color}
 As a <user>,
 I want to <action>
 So I can <motivation>

{color:#654982}*Scope*{color}
||Item||In Scope||
|Countries|<UK/PL/HU/SK/TH/MY>|
|Viewports|<All/Desktop/Mobile/Tablet/Specific pixel range>|
|Devices|<All/Specific device>|
|Client-side JS|<JS only/non-JS only/JS & non-JS>|
|Mode|<Normal mode only/Amend mode only/Normal & Amend modes>|
|Logged in/out|<Whether or not exclusive to logged-in/out>|

<Any other relevant scope details>

{color:#654982}*Design*{color}
 <Zeplin file URL>
 <Clarifying notes>

*{color:#654982}Acceptance Criteria{color}*
   
||#||Given||When||Then||
|1.| | | |
|2.| | | |

 {color:#654982}*Non-JS*{color}
 <Add non-JS detail here>

{color:#654982}*Accessibility*{color}
 <Add accessibility requirements for this ticket>

*{color:#654982}Analytics{color}*
 <Provide analytics requirements as separate, numbered scenarios>

+Analytics Scenario X - <description>+

WHEN <I click on a thing>
 THEN An analytics event should be fired

*{color:#654982}Testing notes{color}*
 <Automation testing: None/details>
 <Other notes for testers>

  *Optimisation Team details*
||Experiment key|oopXXX|
||Variation keys|*Control:*  XXX-X
 *Variant B:* XXX-X|
||Variant details|*Control:*  Current experience|

*Variant B:* <Description of Variant B>
||Test ACTIVATE locations & conditions|<Describe when and how ACTIVATE is called>|
||DEFAULT Audience Attributes|<Details>|
||TEST SPECIFIC Audience Attributes|<None/Details>|
||Optimizely identifier|<CustomerID/TrkID>|
||Optimisation Trello ticket|<Ticket URL>|
||Optimizely QA Project link|<Project URL>|""")
}
if(issue.issueType.name == "Defect"){
issue.setDescription("""{panel:title=Bug Overview|borderStyle=none|borderColor=#80CCFF|titleBGColor=#80DFFF|bgColor=#80DFFF}{panel}
|| Environment:| PPE |
|| Affect versions | 2.3.0 |
|| Country:| IGHS |
|| Viewport:| All viewports |
|| Devices/Browsers:| All devices/browsers |
|| Pages:| Slots page |
|| Steps to reproduce:| # Browse https://nakup.itesco.cz
# Register a new user
# Click on book a slot and choose collection
# Book a collection slot
# Enter collection instruction in the instruction box |
|| Expected: | Instruction should be saved upon typing and should appear in order summary page |
|| Actual: | Instruction is not getting saved and missing in order summary page |
|| Note: | Issue is intermittent with existing users but automation tests are consistently failing for new users (https://ci.ngbeta.net/job/Greenfields/job/grocery/job/master/362/). Also, issue is observed manually for both delivery/collection instructions |
|| Bug video/screenshot: | Video attached |""")}


3 answers

2 accepted

0 votes
Answer accepted
Nikhil June 24, 2019

Hi @Vimalraj 

Below script was working for me try it out

Script:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue


def StoryDefaultDescValue = """[Place your text here]"""

def DefectDefaultDescValue ="""[Place your text here]"""


def projectKey = getIssueContext().getProjectObject().getKey()
def issueTypeName = getIssueContext().getIssueType().getName()


if(issueTypeName == "Story"){
getFieldById("description").setFormValue(StoryDefaultDescValue)}

if(issueTypeName == "Defect"){
getFieldById("description").setFormValue(DefectDefaultDescValue)}


0 votes
Answer accepted
Vimalraj
Contributor
June 21, 2019

Hi Nikhil,

I use scriptrunner to set description in Behavior

def dg_sDefaultDescValue = """[Insert a concise description of the problem.]""".replaceAll(/ /, '');

getFieldById("description").setFormValue(dg_sDefaultDescValue);

 

Thanks,

Vimalraj

Nikhil June 21, 2019

Thank you @Vimalraj for the help

but now i am using this script but still facing the issue.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue

def StoryDefaultDescValue = """
{color:#654982}*Pull Requests & Branches*{color}
<Devs to copy a link to at least the main PR on GitHub for ease>

{color:#654982}*Contacts*{color}
<delete or add to below as appropriate>
||PO||UI Designer||Analytics||Optimisation||
|Col A1|Col A2| | |

{color:#654982}*User Stories*{color}
As a <user>,
I want to <action>
So I can <motivation>

{color:#654982}*Scope*{color}
||Item||In Scope||
|Countries|<UK/PL/HU/SK/TH/MY>|
|Viewports|<All/Desktop/Mobile/Tablet/Specific pixel range>|
|Devices|<All/Specific device>|
|Client-side JS|<JS only/non-JS only/JS & non-JS>|
|Mode|<Normal mode only/Amend mode only/Normal & Amend modes>|
|Logged in/out|<Whether or not exclusive to logged-in/out>|

<Any other relevant scope details>

{color:#654982}*Design*{color}
<Zeplin file URL>
<Clarifying notes>

*{color:#654982}Acceptance Criteria{color}*

||#||Given||When||Then||
|1.| | | |
|2.| | | |

{color:#654982}*Non-JS*{color}
<Add non-JS detail here>

{color:#654982}*Accessibility*{color}
<Add accessibility requirements for this ticket>

*{color:#654982}Analytics{color}*
<Provide analytics requirements as separate, numbered scenarios>

+Analytics Scenario X - <description>+

WHEN <I click on a thing>
THEN An analytics event should be fired

*{color:#654982}Testing notes{color}*
<Automation testing: None/details>
<Other notes for testers>

*Optimisation Team details*
||Experiment key|oopXXX|
||Variation keys|*Control:* XXX-X
*Variant B:* XXX-X|
||Variant details|*Control:* Current experience|

*Variant B:* <Description of Variant B>
||Test ACTIVATE locations & conditions|<Describe when and how ACTIVATE is called>|
||DEFAULT Audience Attributes|<Details>|
||TEST SPECIFIC Audience Attributes|<None/Details>|
||Optimizely identifier|<CustomerID/TrkID>|
||Optimisation Trello ticket|<Ticket URL>|
||Optimizely QA Project link|<Project URL>|""".replaceAll(/ /, '');

def DefectDefaultDescValue ="""{panel:title=Bug Overview|borderStyle=none|borderColor=#80CCFF|titleBGColor=#80DFFF|bgColor=#80DFFF}{panel}
|| Environment:| PPE |
|| Affect versions | 2.3.0 |
|| Country:| IGHS |
|| Viewport:| All viewports |
|| Devices/Browsers:| All devices/browsers |
|| Pages:| Slots page |
|| Steps to reproduce:| # Browse https://nakup.itesco.cz
# Register a new user
# Click on book a slot and choose collection
# Book a collection slot
# Enter collection instruction in the instruction box |
|| Expected: | Instruction should be saved upon typing and should appear in order summary page |
|| Actual: | Instruction is not getting saved and missing in order summary page |
|| Note: | Issue is intermittent with existing users but automation tests are consistently failing for new users (https://ci.ngbeta.net/job/Greenfields/job/grocery/job/master/362/). Also, issue is observed manually for both delivery/collection instructions |
|| Bug video/screenshot: | Video attached |""".replaceAll(/ /, '');

//MutableIssue issue = issue
def issue = event.issue as issue

if(issue.issueType.name == "Story"){
getFieldById("description").setFormValue(StoryDefaultDescValue)}

if(issue.issueType.name == "Defect"){
getFieldById("description").setFormValue(DefectDefaultDescValue)}


0 votes
Nikhil June 21, 2019

Hi @Nic Brough -Adaptavist- 

Can you help me out. Thank you for the help.

 

Regards,

Nikhil

Vimalraj
Contributor
June 21, 2019

Hi Nikhil,

You may have to add behaviour for each issue type and define Description specific to that workflow.

Thanks,

Vimalraj

Suggest an answer

Log in or Sign up to answer