I am trying to change the parentId of a sub-task via a Groovy script in the Scriptrunner Console, but for some reason the change is not actually being saved.
Below, is the code I am using.
As you will see, I am getting the new parent from the change history of the sub-task, as it was moved by mistake. We have multiple cases like this, which is why I am trying to do this via a script.
Any help or guidance is appreciated.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.type.*
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils
def issueManager = ComponentAccessor.getIssueManager();
def changeHistoryManager = ComponentAccessor.changeHistoryManager
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
final String issueKey = 'CLTAST-18782'
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey(issueKey)
def parent = ""
changeHistoryManager.getChangeItemsForField(issue, "Parent").each { def it -> parent = it.getFromString(); log.warn(it.getFromString()) }
if (issue.getParentObject().getKey() != parent){
log.warn ("Not the same parent")
def parentIssue = ComponentAccessor.issueManager.getIssueByCurrentKey(parent)
def parentId = parentIssue.getId()
issue.setParentId(parentId)
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false);
boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
log.warn("Reindex issue ${issue.key} ${issue.id}")
issueIndexingService.reIndex(issueManager.getIssueObject(issue.id));
ImportUtils.setIndexIssues(wasIndexing);
}
You may set "Internet Explorer MIME Sniffing Security Hole Workaround Policy" in Administration -> General Configuration to "Work around Internet Explorer security hole" or to "Insecure: inline display of attachments". You probably have this configured as "Secure: forced download of attachments for all browsers" .
But remember that showing some attachments inline (for example flash animations) may open security holes in your instance.
Does this configuration helped?
I'm on a Mac so an IE solution won't work for me. I'd hate to use IE even if I was on a PC.
I know this use case used to work. I just don't know if the browsers changed or if Jira somehow changed the way it creates the hyperlink for attachments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you check that configuration? It's not only IE related - it works with Firefox, Opera and Chrome and Leopard.
If you have "Insecure: inline display of attachments" set then this may be your browser configuration that causes this behaviour.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I get it now and yes the issue was the 'Internet Explorer MIME Sniffing Security Hole Workaround Policy' setting Jira->Admin->General Config->Options.
It's soooo nice to not have to download a text log file anymore. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello.
This works with txt but what about csv or doc or docx or xlsx?
Please give our solution.
Costumers want just to view attached files, without downloading.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's a browser setting, Jira hasn't changed. Firefox still downloads the attachment inline.
Maybe it's your settings and you need to tell Safari that it's a safe file?
http://www.tikirobot.net/wp/2006/12/03/automatically-opening-your-own-downloaded-files-with-safari/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mmm, that's more a function of the browser than the web-application. You should be able to tell your browser to open text files (and almost anything else) in the browser, rather than downloading and opening it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.