The problem
Hi I am trying to write a script runner simple validator script which validates two fields
What I am trying to do is to check if at least one of them was selected
The customer is multi-select and the Device Related is single select
both are getting the data from Insight objects
Steps I did
This is what I am trying to do
cfValues['Customer'] || cfValues['Device Related']
In this case, I can not create the issue
Using only cfValues['Customer']
Works for customer field (validation works as expected)
Edit
cfValues['Device Related'] alone does not work
I could not find anything in the logs can someone direct me the correct log or what to look for
any ideas?
Hi @Nehemia Litterat ,
I just tried this exact code using Insight fields and it is working as expected. Have you tried all cases and identified which ones work/do not work ? Have you checked the logs ?
Antoine
Thanks for the quick reply
The cases are very simple :)
During the create I am trying to save the issue with values
By the way, something I did not write in the original question is that
cfValues['Device Related']
alone does not work
This is customer env I asked for logs I should get them tommorrow
I will update if I will find something there
It is good to know that my script is valid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I edited the original question
In short, the logs do not show anything
I would be good to know what to look for or in which log to look into
I looked in the application logs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have two custom fields with the same name
only one of them is present on the screen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok so this is the problem
it seems that the issue is that I have two custom fields with the same name
Again only one is on the screen
the reason we did that was to have one for single value select and other is for multi-value select
any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see, you will need to use the ids then :
import com.atlassian.jira.component.ComponentAccessor
int insightId1 = 12001
int insightId2 = 12002
def insightValue1 = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject(insightId1))
def insightValue2 = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject(insightId2))
insightValue1 || insightValue2
As a rule of thumb I strongly disadvise to use two custom fields with the same name. It can quickly become confusing in the scheme configurations, backups, and can mess up your code.
That is also why I recommend to always use id in the code, so that you can rename the custom field without consequence.
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, I took your advice
deleted the second field
and now I will add validation for choosing only one value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.