You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi everyone,
I am trying to link a field in Jira to SQL database. I would like to filter the values based on another field called "Location". The script works fine during initial selection but the list can not be modified afterwards so if the user had forgot to add an asset they have to delete all previously selected assets and re-enter them. I am not sure how I can use original values to be passed in new search query. Here is my code that works initially but throws error after updating:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.customfields.option.Option import com.onresolve.scriptrunner.canned.jira.fields.editable.database.SqlWithParameters def customFieldManager = ComponentAccessor.customFieldManager getSearchSql = { String inputValue, Issue issue, String originalValue -> def customField = customFieldManager.getCustomFieldObjects(issue).findByName('Location') def Lab_Location = issue.getCustomFieldValue(customField) as Option new SqlWithParameters( "select ID, Local_Name, Lab_Location from assets where lower(Local_Name) like concat('%', lower(?), '%') and Lab_Location = ?", [inputValue, Lab_Location?.value] ) } getValidationSql = { String id, Issue issue, String originalValue -> def customField = customFieldManager.getCustomFieldObjects(issue).findByName('Location') def Lab_Location = issue.getCustomFieldValue(customField) as Option new SqlWithParameters("select ID, Local_Name, Lab_Location from assets where ID = CAST(? AS SIGNED) and Lab_Location = ?", [id, Lab_Location?.value]) }
@Mojtaba MansouriI also find this difficult to configure, but I was able to get the following code to work for my database picker. The parent field is 'Purchase Order'. The child field (this field) is the line items on the Purchase Order.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.