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;
}