How can I get remaining time in Script Runner

GG
Contributor
March 19, 2023

Hi,

The following script in Script Runner used to work, but after updating Jira and Script Runner, code does not work. What changes should I make in the  script?

if((long)timeToResolution.getCompleteSLAData().get(0).getRemainingTime()>0)

 

Regards

GG

1 answer

0 votes
habib rahman
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.
March 19, 2023

Hi @GG My name is Habib - 

Without more information about the error message or the context of the script, it's difficult to provide a specific solution. However, here are some suggestions that might help:

  1. Check the API documentation for the `getCompleteSLAData()` method to see if there have been any changes to its return type or behavior in the updated version of Script Runner. If so, you may need to update your code accordingly.
  2. Check if the `timeToResolution` object is still valid and has the expected data. It's possible that the object has changed and is no longer compatible with the `getCompleteSLAData()` method.
  3. Check if there are any new dependencies or libraries required by the updated version of Script Runner. If so, you may need to add them to your project or update the existing ones.
  4. Check the logs or error messages for any specific information about the problem. This may provide insights into the specific changes needed to fix the code.

 

Here is an example of how the code might be updated to handle any changes in the
`getCompleteSLAData()` method:```java
List<SLAData> slaDataList = timeToResolution.getCompleteSLAData();
if (slaDataList != null && !slaDataList.isEmpty()) {
    long remainingTime = slaDataList.get(0).getRemainingTime();
    if (remainingTime > 0) {
        // Do something
    }
}
```
This version of the code checks if the `slaDataList` object is not null and not empty before accessing its elements. It also assigns the value of `getRemainingTime()` to a separate variable for readability and debugging purposes.
I hope this helps.
Habib 
GG
Contributor
March 21, 2023

Thanks for your response Habib.

I will check it and let you know the result.

Regards

GG

Like habib rahman likes this

Suggest an answer

Log in or Sign up to answer