I've created a Script fragment to create a subtask, Please see below xml similar to the one mentioned here(https://community.atlassian.com/t5/Product-Apps-questions/Scriptrunner-web-fragments-for-creating-subtask-with-default/qaq-p/55927)
<span><web-item</span> <span>key</span><span>=</span><span>'createFeed'</span> <span>name</span><span>=</span><span>'ScriptRunner generated web item - createFeed'</span> <span>section</span><span>=</span><span>'operations-top-level'</span> <span>weight</span><span>=</span><span>'1'</span><span>></span> <span><label></span><span>Feed</span><span></label></span> <span><condition</span> <span>class</span><span>=</span><span>'script:jiraHelper.project?.key == "ABC"&issue.issueType.name == "Story"'</span><span>/></span> <span><styleClass></span><span>issueaction-create-subtask</span><span></styleClass></span> <span><link</span> <span>linkId</span><span>=</span><span>'createFeed'</span><span>></span><span>/jira/secure/CreateSubTaskIssue.jspa?parentIssueId=${issue.id}&pid=${issue.projectObject.id}&issuetype=11111</span><span></link></span> <span></web-item></span>
Error: I have 2 subtasks types, because of jira's default behavior the issue type is selected to the latest subtask issue type created.
Steps taken to solve the error: I tried using the Behaviours integration to set the issue type to default, Please see below script as mentioned in the documentation:https://scriptrunner.adaptavist.com/4.1.3.24/jira/fragments/CreateConstrainedIssue.html#_behaviours_integration
<span>import</span><span> com</span><span>.</span><span>atlassian</span><span>.</span><span>jira</span><span>.</span><span>component</span><span>.</span><span>ComponentAccessor</span> <span>import</span><span> com</span><span>.</span><span>atlassian</span><span>.</span><span>jira</span><span>.</span><span>issue</span><span>.</span><span>IssueManager</span><span>;</span> <span>def</span><span> issueManager </span><span>=</span> <span>ComponentAccessor</span><span>.</span><span>getIssueManager</span><span>()</span> <span>if</span> <span>(</span><span>getBehaviourContextId</span><span>()</span> <span>==</span> <span>"createFeed"</span><span>)</span> <span>{</span><span> getFieldById</span><span>(</span><span>"issuetype-field"</span><span>).</span><span>setReadOnly</span><span>(</span><span>true</span><span>)</span> <span>}</span>
But this doesn't work. Am I missing anything or is this because of the styleClass I've used. issueaction-create-subtask
I need the subtask screen to popup when the script fragment button is clicked, with the issue type field set as read only.
Pleas advise. Thanks.
Hello,
In the following line
<span>getFieldById</span><span>(</span><span><span>"issuetype-field"</span></span><span>).</span><span>setReadOnly</span><span>(</span><span><span>true</span></span><span>)</span>
What do you use for issuetyle-field? It must be like customfield_<id>. If you use the name of the custom field you need to call getFieldByName method.
It looks like you're new here. Sign in or register to get started.