Script Runner: Using JQL functions from other plugins

Lukasz Chomin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 17, 2015

Hi,

I'm using in my script this JQL function from Profields plugin:

SearchService.ParseResult parseResult = searchService.parseQuery(ApplicationUsers.toDirectoryUser(user), "project in profieldsOperator(Language,\"=\",EN)")

When I run this script from Script Console everything works properly. But when I run it from script file as a scheduled service I get this error:

Script Runner [jira.profields.jql.JqlFunctionProfieldsOperator] Error JQL function profields when execute getValues() in class com.deiser.jira.profields.jql.JqlFunctionProfieldsOperator

 

What could be the reason for such error?

Thanks in advance for your help.


Best regards,

Lukasz Chomin

2 answers

1 accepted

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2015

There is no user context in a service - you will need to set one with something like:

ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(User or ApplicationUser)

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2015

but JQL functions should handle this more gracefully...

0 votes
Lukasz Chomin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 17, 2015

Hi Jamie,
Thanks for your prompt reply.
You are genius, adding this one line solved the issue.

BTW. Having this opportunity, may I transition an issue and add comment in the same step? Currently I'm doing this with two methods:

commentManager.create(issueManager.getIssueObject(issue.id), user, comment, true);
...
workflowTransitionUtil.setAction(1021);

and therefore I'm getting two notifications.
It would be much more user friendly to just get one.

Regards,

Lukasz

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2015

This is a different question really... but wtu.setParams([comment: "my comment"]) might work... I've moved to using IssueService, but that has its own problems.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events