Snippets

Adaptavist Example DB Picker Configuration Script to filter DB Picker Options based on the Project selected - Jira DC

Created by Ram Kumar Aravindakshan
/*
 * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner
 * license shall be granted a  non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed
 * or amended and must be included in any circumstances where the code snippet is shared by You or a third party."
 */

import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.canned.jira.fields.editable.database.SqlWithParameters

def columnName = 'Country_Name'

getSearchSql = { String inputValue, Issue issue, originalValue ->

    if (issue.projectObject.name == 'Mock') {
        new SqlWithParameters("""
        select ID, COUNTRY_NAME from COUNTRIES
        where ${columnName} in (?,?,?)
        """, ['India', 'United States', 'United Kingdom'])

    } else if (issue.projectObject.name == 'Example') {
        new SqlWithParameters("""
        select ID, COUNTRY_NAME from COUNTRIES
        where ${columnName} in (?,?)
        """, ['Malaysia', 'Singapore'])
    } else if (issue.projectObject.name == 'Sample') {
        new SqlWithParameters("""
        select ID, COUNTRY_NAME from COUNTRIES
        where ${columnName} in (?,?)
        """, ['Japan', 'Australia'])
    }
}

renderViewHtml = { displayValue, row ->
    displayValue
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.