I have the requirement of setting a date field according to SLA.
e.g. If the issue matches SLA goal 1, which has a duration of 10 days, then I am to set the date field to today + 10 days.
While there is no API to retrieve SLA settings (for the project, not a specific issue), I managed to grab the goals from database directly:
SELECT
g.JQL_QUERY, g.TARGET_DURATION
FROM
"AO_54307E_GOAL" g
JOIN "AO_54307E_TIMEMETRIC" tm ON tm.ID = g.TIME_METRIC_ID
JOIN "AO_54307E_SERVICEDESK" sd on tm."SERVICE_DESK_ID" = sd."ID"
JOIN project p on sd."PROJECT_ID" = p.id
WHERE
p.pkey = 'PROJ1'
And I know I can execute JQL query from ScriptRunner:
The problem is my issue could be in memory (in ScriptRunner mail handler, not saved yet).
How can I compare my in memory issue against the JQL?
I can probably save the issue first then update timeline as a workaround, but ideally I want to do it before saving.