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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.