Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using queryDslAccessor with scriptrunner?

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 17, 2024

Hi!

Did someone ever manage to use QueryDslAccessor properly?

I have a custom REST endpoint with scriptrunner in Jira to import issues from another system.

A step I'm missing is to alter the updated date which can not be done with the IssueManager or any other obvious methods I'm aware of.

I read about QueryDslAccessor but it does not seem to update anything.

In this example I try to alter the summary. The real use-case is to alter the updated date. But even this is not working:

 

 

import com.atlassian.jira.database.QueryDslAccessor

import com.atlassian.jira.model.querydsl.QIssue

import com.atlassian.jira.component.ComponentAccessor

def issue = ComponentAccessor.IssueManager.getIssueObject("DET-12")

QueryDslAccessor queryDslAccessor = ComponentAccessor.getComponent(QueryDslAccessor.class);

QIssue qissue = QIssue.ISSUE

     queryDslAccessor.execute(dbConnection -> {

             dbConnection.update(QIssue.ISSUE)

                     .set(QIssue.ISSUE.summary, "Hello World")

                     .where(QIssue.ISSUE.key.eq(issue.key))

                     .execute();

     });
I'm executing this in the Script Console just to test.
There is no error but when I look at that issue in the UI or in the database directly nothing changes.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 18, 2024

Hi @Charlie Misonne,

Have you tried using ScriptRunner's HAPI feature?

With HAPI, there are simpler ways to update the issue. For example:-

def issue = Issues.getByKey('ABC-1')
            
issue.update {
   setSummary('an updated summary')
   setDescription('hello *world*')
}

For more information on updating issues with HAPI, please refer to this ScriptRunner Documentation.

I am looking forward to your feedback.

Thank you and Kind regards,
Ram

 

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 19, 2024

Hi Ram,

Thanks for your answer. Yes I used HAPI in the past.

But can I updated the updated date of an issue with HAPI? I don't think so but if I'm overlooking it please let me know.

As mentioned in my question it is the updated field I need to adapt. In my example I only used summary to simplify the case to make sure I did not run into any date formatting issues.

TAGS
AUG Leaders

Atlassian Community Events