How add Re-index in my code ?

Alex
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.
October 25, 2022

Hello everyone, I have an SLA counter, which, depending on whether the time has expired or not, has the status "Ok" or "Fail".
My problem is that the tasks don't change the index after changing the result on the spinner, which restricts searching through JQL. Only manual reindexing solution worked for me .When I do reindexing with my hands, only then I get all the tasks in the search
From the link below. https://docs.adaptavist.com/sr4js/6.57.0/features/built-in-scripts/re-index-issues?utm_source=product-help 

Is it possible to add this somehow to my code? 
My code

https://drive.google.com/drive/folders/1xPmWrKHTCv-SUh7vO6J0hzdwmYXJoOFA 

Thank you!

уауй.png

1 answer

1 accepted

1 vote
Answer accepted
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2022
def setSLA(issue, value) {
fieldName = 'Counter status'
customFieldManager = ComponentAccessor.getCustomFieldManager()
customField = customFieldManager.getCustomFieldObjectByName(fieldName)
if (customField.getValue(issue).toString() != value) {
fieldConfig = customField.getRelevantConfig(issue)
optionsManager = ComponentAccessor.getOptionsManager()
option = optionsManager.getOptions(fieldConfig).find { it.value == value }
changeHolder = new DefaultIssueChangeHolder()
customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), option), changeHolder)
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
issueIndexingService.reIndex(issue)
}
}
Alex
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.
October 26, 2022

@Tom Lister  Hi! It worked! Thank you very much!!! You just have no idea how much you helped with this issue! Many thanks to you !!!

Alex
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.
January 27, 2023

Suggest an answer

Log in or Sign up to answer