Messing with Behaviors....
What I am trying to do is to determine is a currently opened screen is an Edit screen.
As I see it, I have to get a current screen scheme and screen id assigned as an Edit screen in it.
Then I have to get a currently opened screen id and compare them.
Googled it a lot ad tried dozens of code examples, but keep bumping on basically the same kind of dead ends. Either I cant get current issue id (what is needed in one kind of code), or I get something like this:
groovy.lang.MissingPropertyException: No such property: IssueOperations for class:
The Goal is to determine is opened screen is an Edit screen. Maybe the is an other way to do that.
Hello,
The code would be like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.operation.IssueOperations
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("issuekey");
def screen = ComponentAccessor.getIssueTypeScreenSchemeManager().getFieldScreenScheme(issue).getFieldScreenSchemeItem(IssueOperations.EDIT_ISSUE_OPERATION )
log.error("eidt screen id" + screen.getId())
Or
import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("issuekey");
def screen = ComponentAccessor.getIssueTypeScreenSchemeManager().getFieldScreenScheme(issue).getFieldScreenSchemeItems().find {
it.getIssueOperationName() == "admin.issue.operations.edit";
}
log.error("eidt screen id" + screen.getId())
Hello Alexey,
Once again you are helping me out :)
The first code doesn't work in my situation because using code in the Behaviors the last one could not import "...operation.IssueOperations", so IssueOperations.EDIT_ISSUE_OPERATION can't be used:
groovy.lang.MissingPropertyException: No such property: IssueOperations for class: Script1
The second one with a bit of modification does what I need. In situation with Behaviors, to get an issue object/key we have to use:
def issueId = formContents["id"]
def issueOBJ = ComponentAccessor.getIssueManager().getIssueObject(issueId as Long)
// or
def issueOBJ = getUnderlyingIssue()
Lyrical digression...
I thought that if I'll get an IssueOperationName it would be equivalent to "IssueOperations.EDIT_ISSUE_OPERATION", and if I'll put it into getFieldScreenSchemeItem() I would get what I want. So I started to play with loops trying to fetch info i need.
def VAR_1 = scrscheme_1.getFieldScreenSchemeItems()
VAR_1.each {
log.debug (" ")
log.debug (" IT " +it)
if(it.getIssueOperation()){
log.debug (" OPERATION ID " +it.getIssueOperation().getId())
log.debug (" OPERATION KEY " +it.getIssueOperation().getNameKey())
log.debug (" OPERATION DEC " +it.getIssueOperation().getDescriptionKey())
log.debug (" OPERATION NAME " +it.getIssueOperationName())
}
}
I was wrong.
But it gave me a thought that from that loop I сan get what I need by taking an IssueOperation with the name I need ("admin.issue.operations.edit").
I was close :) Thank you for saving my time :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've just understood, that this code:
def screen = ComponentAccessor.getIssueTypeScreenSchemeManager().getFieldScreenScheme(issue).getFieldScreenSchemeItems().find {
it.getIssueOperationName() == "admin.issue.operations.edit";
}
returns an "Item" (...getFieldScreenSchemeItems().find...)
and
screen.getId()
returns an ID of that item.
So to get a Screen ID we need to use:
screen.getFieldScreenId()
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What Jira version do you use?
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.
This is strange. I tested my code in a behavour but my version is 7.2.3
And I had a look in the Api reference this class is available in your Jira version
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes it is (atleast it has to be...), I've checked atlassian docs (docs.atlassian.com/jira/6.2.4/) and it is there, but when I try to import it at behaviors script
import com.atlassian.jira.issue.operation.IssueOperations
I get
Compilation failure: startup failed: Script1.groovy: 6: unable to resolve class com.atlassian.jira.issue.operation.IssueOperations @ line 6, column 1. import com.atlassian.jira.issue.operation.IssueOperations ^ 1 error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I ll have a look if a docker image is available for your Jira version, I ll pull it and try at home
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, thank you. Besides it happens and with other classes for example:
import com.atlassian.jira.issue.fields.screen.FieldScreenManager import com.atlassian.jira.issue.fields.screen.FieldScreen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just checked my current jira instance and downloaded same version from atlassian. Well these classes are missing in 6.2.4 version.
I wonder what will happen if I'll just put them from newer jira version.
In theory nothing bad should happen instantly, because if they are missing, means jira does not use them. The should not be any code in jira wich would rely on these missing classes.
The interesting part should start when I'll try to use them in a script....
Well... :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just do not do it in production :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Challenge accepted! :D
Just kiding, I'm too chickenshit to do it in production :)
I'm little confused... and I'm definitely looking for these classes in a wrong place, because I thought they all should be placed in:
atlassian-jira\WEB-INF\classes\com\atlassian
IssueOperations
atlassian-jira\WEB-INF\classes\com\atlassian\jira\issue\operation
FieldScreen
FieldScreenManager
atlassian-jira\WEB-INF\classes\com\atlassian\jira\issue\fields\screen
etc.
But these directories (in any version of jira I've dowloaded 6.2.4-7.5.2) does not contain any of *.class which I am looking for (there are other classes in these dirs, but not the ones I need).
So I gess they are present in some other form (inside of some *.jar, etc.)
UPDATE:
It was ScriptRunner v3.0.5 issue. When I updated it to v3.0.16 it resolved the problem with certain *.class import.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nice to hear. Good job.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So I managed to get Screen scheme
import com.atlassian.jira.component.ComponentAccessor
def scrscheme = ComponentAccessor.getIssueTypeScreenSchemeManager()getFieldScreenScheme(getUnderlyingIssue())
Now I have to get Operation Screen. Something like:
scrscheme.getFieldScreen(IssueOperation issueOperation)
But how can I specify, for example EDIT screen?
IssueOperation issueOperation
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.