Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
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

Link with context issue

Hello,
I'm implementing a create issue button "Sub-Story" using script fragment. I'm using behaviors to default the summary, components and create a link between the new issue and the context issue.

All this is working good as long as we do not change the project on the screen. If we select the project to a different one, the behaviors is not working: i.e the components and issue link field is going back to empty.

We would like to have the same capability even if the project is changed i.e the components and link issue field should be defaulted from the context issue.

Please advice.

Thanks.

1 answer

Hi Veera,

What is the configuration for your behaviour like? Is it mapped to a specific project?

Please can you show me the code you are using and the details of the configuration of the behaviour. 

Thanks

Johnson

Hi Johnson,

Please see the behavior below.

import com.atlassian.jira.issue.IssueManager;
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager


def issueManager = ComponentAccessor.getIssueManager()
def CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

getFieldById("issuelinks-linktype").setFormValue("Original")

if (getBehaviourContextId() == "CreateSubStory") {
def contextIssue = issueManager.getIssueObject(getContextIssueId())
getFieldById("issuelinks-linktype").setFormValue("Original").setReadOnly(true)
getFieldById("project-field").setFormValue(contextIssue.getProjectObject().name)
getFieldById("issuetype-field").setReadOnly(true)
getFieldById("summary").setFormValue(contextIssue.summary)
getFieldById("issuelinks-issues").setFormValue(contextIssue.key).setReadOnly(true).setHidden(true)
}

Thanks.

Hi Veera,

Have you added this as an initialiser or is it mapped to a field?

I think I will need to see the configuration screen in order to understand this issue fully.

I cam see that you set the project field to match the context issue, therefore I assume this is not an initialiser as this code will change the project back to the context issue project even if you change it to a different one.

Also, is the issue type configured for both projects (the original and the one you change it to) ?

Thanks

Johnson 

Hi @JohnsonHoward,

The behavior is mapped as an initialiser.

I cam see that you set the project field to match the context issue, therefore I assume this is not an initialiser as this code will change the project back to the context issue project even if you change it to a different one.---- This doesn't happen. I'm able to change the project.

Also, is the issue type configured for both projects (the original and the one you change it to) ?-YES

Please let me know if you need any more info

Thanks.

Hi Veera rdy,

Have you tried checking the logs for more information. Also, logging out information from the behaviour scripts. 

Like this:

 log.info("CONEXT" + getBehaviourContextId().toString())

If you put this before the if statement you will be able to see if the context you are looking for is correct. 

There is a ScriptRunner built-in script called 'View Server Log File' , go on this and choose 'atlassian-jira-log' from the drop down, then click your script fragment and change the project type, then run the log file builtin script to see what gets output. 

Did you find any solution to this? 

I am experiencing the same problem. The initialiser works as expected, but as soon as we change Project or Issuetype, it seems like the form "forgets" everything about the context issue and just becomes a fresh Create Screen dialog. (Except if you have anything in Summary, but that is a different story.) 

If I try to use Server Side script, it works as long as Project and Issuetype is not changed, but as soon as any of these are changed, the Create Issue dialog knows nothing about the context issue anymore...  

I also tried to copy the context issue key to a temporary textfield, but all fields (except Summary) are cleared as soon as Project or Issue Type is changed, so no luck. 

Not sure how to solve this without creating a button for each project, which is a no go really.... 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

317 views 3 20
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