The short, how can I update another custom field of the same issue?
I have code that runs through a calculation and returns the result to a JMCF custom field and attempting to copy the value to another custom field using setFieldValue but run into the error.
java.lang.IllegalStateException: Calling setFieldValue() from this context is not authorized.
Does that mean the control doesn't exist yet? Any tricks to get this working?
Update:
Forgot to add that I have code that allows overwriting the calculated value so the other field's role is to always display the calculated value.
Clear as mud?
Thanks.
While you can’t directly write to another field from a JMCF (Jira Misc Custom Fields) scripted field (since it’s read-only by design), there are a few reliable workarounds depending on your use case and toolset.
Workaround Options to Copy JMCF Value to Another Field
1. Use a Workflow Post-Function (JMWE or ScriptRunner)
Best for: Updating a real custom field with a calculated value during a workflow transition.
def calculatedValue = // your calculation logic
issue.setCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Target Field"), calculatedValue)
2. Use an Automation Rule (Jira Automation or ScriptRunner Listener)
Best for: Automatically syncing values when an issue is created or updated.
3. Use a Scheduled Script (ScriptRunner)
Best for: Bulk syncing JMCF values to a writable field (e.g., nightly job or fixup).
Script sample:
def jmcField = customFieldManager.getCustomFieldObjectByName("Calculated JMCF Field")
def targetField = customFieldManager.getCustomFieldObjectByName("Synced Field")
def issues = jqlSearchProvider.search("project = XYZ", ...)
issues.each { issue ->
def value = issue.getCustomFieldValue(jmcField)
issue.setCustomFieldValue(targetField, value)
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
}
4. Replace the JMCF with a “Writable” Field + Background Sync
Best for: When users need to override the calculation but still see updated results.
What Does Not Work
Response provided by Jer-nee Consulting, an Atlassian Gold Solutions Partner. We are here to support your success, let us know if you have any other questions or issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.