Just upgraded JIRA v.8.16.1 and ScriptRunner 6.37.0. I read that ComponentManager is deprecated and now I have to refactor this using by ComponentAccessor. But, I got "static type checking - the variable [issueManager] is undeclared." error. I am very unfamiliar with this language. Can you please help to convert it by using ComponentAccessor?
Below, I try to explain changes.
//BEFORE
//issueManager = ComponentManager.getInstance().getIssueManager();
//AFTER
issueManager = ComponentAccessor.getIssueManager();
void createSubtask(String issueType) {
..
//below line shows an error. static type checking - the variable [issueManager] is undeclared.
subTask = issueManager.createIssueObject(authenticationContext.getLoggedInUser(), issueObject);
}
Hi @MM B ,
That makes sense since you did set the variable issueManager but you didn't tell it what it is. Maybe you also commented that out?
A quick fix would be to do a
def issueManager = ComponentAccessor.getIssueManager();
def is basically a catchall and you can put all types of objects in it. It will restrict you from getting type-ahead/checks but it will catch any type you put in to it.
Hi @Dirk Ronsmans,
Thank you for your quick response.
Yes, you're right. I accidentally skipped the "def" while typing it here. Original code is as follows. I marked bold the line causing the error. Static type checking error happens, when I use the issueManager in the createSubtask method.
//BEFORE
//issueManager = ComponentManager.getInstance().getIssueManager();
//AFTER
def issueManager = ComponentAccessor.getIssueManager();
void createSubtask(String issueType) {
..
//below line throws an error. static type checking - the variable [issueManager] is undeclared.
subTask = issueManager.createIssueObject(authenticationContext.getLoggedInUser(), issueObject);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But does it actually error out? Cause if you don't put a specific type but "def" then it doesn't really know what it is and it will throw some warnings.
The code however will execute without an issue.
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.