Hello,
I write a behaviour that set default description data while creating "Bug-Internal" and "Sub-Bug" types (By Map).
It worked ok, But also all other types set this description..
How can I clear this in other types? I try with a condition but it still worked on all types.
this is my code:
def desc = getFieldById("description")
//def issueType = getFieldById("issuetype")
def defaultValue = """h3. General OS / DB / Browser / Machine Information:
====================================
h3. Scenario Description and steps to recreate the problem:
====================================
**
h3. Actual & Expected Results
====================================
**
**
h3. Log file information:
====================================
h3. Additional info (Optional):
==================================== """
if ((issueContext.issueType.name !="Bug-Internal") && (issueContext.issueType.name !="Sub-Bug")){
desc.setFormValue("")
}
else {
desc.setFormValue(defaultValue)
}
Hello @Dan27
Where are you place your code? I check it and it works pretty well.
You need to map it to issuetype field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here example for last version of scriptrunner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can your provide screenshot of your configuration?
You need to create behaviour like this
1) Add-ons -> Behaviours -> Add
2) Add mapping to your project and all issue types
3) Fields -> Add "Issue Type" field
4) On added field add serverside script and place your code here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
As I understand, you are setting the behaviour with a mapping that affects only Bug-Internal and Sub-Bug issuetypes and then, inside your code, you are setting the description field based on the issuetype (again).
That's the problem, let me explain myself:
As far as you set the mapping for only Bug-Internal and Sub-Bug, when you choose one of these issuetypes the field will be set correctly because it triggers the behaviour, but when you change to another issuetype they will not use the behaviour as you didn't set them on the mapping.
So, this part of the code if ((issueContext.issueType.name !="Bug-Internal") && (issueContext.issueType.name !="Sub-Bug")) is redundant with the mapping and will not be used when you choose a different issuetype.
I'm not sure of which is the very best way to do this, but if you don't specify the issuetype on the mapping (only specify the project(s)) it should work with your current code.
Hope it helps.
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marcos Sanchez I didn't understand.. Remove the Map (Choose all types) and leave the condition inside the code ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes, choose all types (but defining the project, of course).
As I said, maybe there could be better ways to do this, but I'm not sure of which ways are...
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.