Hello!
I am trying to set a custom field of URL-type during the creation of a ticket, but it doesn't set the value at all. If I run the same code during another transition it works, so the code seems to be ok.
I have tried to change the order of the post function steps after reading a couple of other questions and answers, but with no luck.
I had the same problem before when setting the Resolution during creation (I know, it's a bit weird, but neeeded in this scenario). That worked after adding the post function "Stores updates to an issue (no change history is created)." before re-indexing.
So, here is my setup.
Post-functions:
- Creates the issue originally.
- ScriptRunner workflow function - Custom script post-function (inline script).
Adds the link to the ticket No failures in the last 15 execution(s) - Stores updates to an issue (no change history is created).
- Re-index an issue to keep indexes in sync with the database.
- Fire a Issue Created event that can be processed by the listeners.
And my code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
def issueId = issue.getKey()
log.info(issueId)
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("<My field name>")
def link = "https://myurl.com/" + issueId
log.info(link)
issue.setCustomFieldValue(customField, link)