We have been using a script (copied below) in Scriptrunner for Jira Data Center 6.54.0 that displays a button on a transition screen that creates a Confluence page from a specific template and takes the user to that page directly to edit and publish. However, we are currently attempting to upgrade our Jira/Confluence and the script no longer functions due to the new requirement of the "atl_token" security requirement in Confluence. Unfortunately, it appears there is no way to call the user's Confluence atl_token from the Jira Scriptrunner side, currently it only calls the Jira atl_token.
Does anyone know if there is any modifications we can make to disable or get around this atl_token requirement? Thank you!
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import java.util.Calendar
import java.text.SimpleDateFormat
import java.sql.Timestamp
import java.text.DateFormat
import java.util.Date
import javax.servlet.http.HttpServletRequest
import com.atlassian.jira.security.xsrf.XsrfTokenGenerator
import com.atlassian.sal.api.auth.LoginUriProvider
import com.atlassian.sal.api.user.UserManager
import com.atlassian.sal.api.auth.Authenticator
import javax.servlet.http.HttpServletRequest
import com.atlassian.jira.web.ExecutingHttpRequest
import com.atlassian.annotations.security.XsrfProtectionExcluded
XsrfTokenGenerator xsrfTokenGenerator = ComponentAccessor.getComponent(XsrfTokenGenerator)
String atl_token = xsrfTokenGenerator.generateToken(null)
def issue = underlyingIssue
def summary = issue.getSummary()
def issueKey = issue.getKey()
def month = new Date().format('MMMM')
def year = new Date().format('YYYY')
String[] sum = summary.toString().split(":")
def shortsum = sum[0].toString().substring(0)
def url2 = "%20&body=" + issueKey + " " + "&linkCreation=true&&fromPageId=63176868"
def durl2 = "%20&body=" + issueKey + " " + "&linkCreation=true&&fromPageId=151355988"
def completeURL = url + url2
def dcompleteURL = durl1 + durl2
def finalURL = """
<html>
<style>
.button {
background-color: #1c87c9;
border-color: #04AA6D;
color: white;
padding: 20px 34px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 4px 2px;
cursor: pointer;
</style>
<body>
<h5 style="color:#ff482e";><kbd>Middle Mouse Button</kbd> <br> <small>OR</small><br><kbd>Ctrl</kbd> + <kbd>Left Click</kbd> on Button below to Open in New Tab (Otherwise you will need to redo this form)</h5>
<a class="button" href="""+ '"' + completeURL + '"' + """>Create Confluence Page HERE</a>
</body>
</html>"""
def dfinalURL = """
<html>
<style>
.button {
background-color: #1c87c9;
border-color: #04AA6D;
color: white;
padding: 20px 34px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 4px 2px;
cursor: pointer;
</style>
<body>
<h5 style="color:#ff482e";><kbd>Middle Mouse Button</kbd> <br> <small>OR</small><br><kbd>Ctrl</kbd> + <kbd>Left Click</kbd> on Button below to Open in New Tab (Otherwise you will need to redo this form)</h5>
<a class="button" href="""+ '"' + dcompleteURL + '"' + """>Create Confluence Page HERE</a>
</body>
</html>"""
// Get Confluence Page Created field
def formField = getFieldById(getFieldChanged())
def Conf = getFieldById("customfield_13919")
// Get Baseline Change Required custom field
def base = getFieldById("customfield_13359")
String baseVal = base.getValue()
// Condition if baseline change required = yes then make Confluence Page Created required and set Help Text to URL Button
if (baseVal == "Yes") {
formField.setHelpText(finalURL)
if (issueKey.startsWith("DINF")) {
formField.setHelpText(dfinalURL)
}
formField.setDescription("")
Conf.setRequired(true)
} else {
formField.clearHelpText()
Conf.setRequired(false)
}