Hi
I am using the insight post function" Set the value of an object attribute with a predefined value" to update the insight attribute "Status" with the value "Running" if no other issues are open for the same service:
I can get the issues from this query:
"project = INC AND issuetype = Incident and status not in (Completed,Canceled,Closed)"
I am tring to write the grivyscript below, can any one help me to check if there any issue which have the same service so the post function will not update the attribute :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.search.SearchQuery
// The JQL query to search with
final jqlSearch = "project = INC AND issuetype = Incident and status not in (Completed,Canceled,Closed)"
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def searchResults = searchProvider.search(SearchQuery.create(jqlSearch, user), PagerFilter.unlimitedFilter)
/// The name of the custom field to alter
final Service = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12345)
def value = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12345)); // Change ID to the correct one
/* If an insight custom field has an object called the same issue service it will fail */
if {
return false;
}
Hi @Juhaina Almama ,
to run a JQL query with groovy and return the list of issues, you can use the SearchService together with the JqlQueryParser, PagerFilter and UserManager.
instead of "searchProvider.search", try jqlParser.parseQuery and searchService.search(...
Hope this helps, if you are still stuck, let me know!
Hi Tessa
Thanks for answering.
I am just a beginner in this kind of script, can you help me more ? such as rewriting the entire script.
how is it to check all the issues that come from the query?
Regads Juhaina
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.