The following script scans your other formulas for any that use functions unsupported in the Cloud version of Structure.
It returns results in the following format: view name, column: function name
-
view name: The view where the formula is located.
-
column: The specific column that holds the formula. Returns
nullif the column is not using a custom name. -
function name: The name of the unsupported function.
Results are shown in the Logs tab of the console. Logs only show the first 300 results. If you exceed this limit you can find the full results in the logs for your Jira space.
Groovy
import com.almworks.jira.structure.api.StructureComponents
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import org.json.JSONObject
import java.util.regex.Pattern
@Grab(group = 'com.almworks.jira.structure', module = 'structure-api', version = '*')
@WithPlugin('com.almworks.jira.structure')
StructureComponents components = ScriptRunnerImpl.getPluginComponent(StructureComponents)
def vm = components.viewManager
def potentialProblems = Pattern.compile(
'(?i)\\battachments
b' +
'|\\bremoteLinks
b' +
'|\\bresolution
b' +
'|\\bpriority
b' +
'|\\whistory
b' +
'|\\baccess
(' +
'|\\bget
(' +
'|\\bme
(' +
'|\\buser_\\w+
(' +
'|\\bdate
(' +
'|\\bdatetime
(' +
'|\\bSJQL
b' +
''
)
def views = vm.getViews(null)
def ctr = 0
views.each { view ->
def columns = view.specification.columns
columns
.findAll { it.key == 'formula' }
.each {
def formulaText = it.parameters['formula'] as String;
if (potentialProblems.matcher(formulaText).find()) {
log.warn(view.name + ', ' + it.name + ': ' + formulaText)
ctr++
} else if ('wiki' == (it.parameters['displayFormat'] as JSONObject)?.opt('type')) {
log.warn(view.name + ', ' + it.name + ': makes wiki markup')
ctr++
}
}
}
ctr