I have a check box that if checked it needs to validate that a separate custom field needs to contain data or the ticket cannot be closed. however if the check box is not checked the the custom field can remain empty.
Hello @Irshad Sheik
It's not possible out of the box, I have implemented something similar using the Behvaiour module of the Script runner paid plugin.
Possible duplicate
Hello @Irshad Sheik
Have you gone through the link which I have shared above as it contains a pretty similar code snippet which is required in your scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i have gone thru the link, but im still struggling on this, ive gotten so far:
def checkBoxField = getFieldByID()
def checkBoxFieldVal = checkBoxField.getValue()
def BI = getFieldByName('Billing Instruction')
if (checkBoxFieldVal == 1){
}
not sure if im on the right path or whats left.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Irshad
I'm afraid it is not possible with out-of-the-box Jira validators.
You should use something like Power Scripts For Jira to create a custom validator with if-else conditions.
Here is an example of script that could be helpful
https://confluence.cprime.io/display/TR/Validators#Validators-Forceacustomfieldtoberequiredifanotherfieldwassettoacertainvalue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Morning
i tried the following and am getting an error:
string errorMsg = "Please enter Billing Instruction Number";
if (customfield_13500 == 1 && !hasInput("customfield_13600")) {
return false,"customfield_13600", errorMsg;
}
the comma after false is producing an error saying expecting } but got ,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think there is some error in how you specifying custom fields and its value.
On my test instance it throws a different error and if i change fields to those i got on my instance and hit Check it says "Looks good"
Try to use this
string errorMsg = "Please enter Billing Instruction Number";
if ("customfield_13500" == 1 && !hasInput("customfield_13600")) {
return false, "customfield_13600", errorMsg;
}
Also you should open any issue that contains those fields with JSON representation and check if field names and value you specifying are correct.
For JSON representation
https://<your jira URL>/rest/api/2/issue/<issuekey>?expand=names
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
would it matter that im using script runner and not power scripts??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes. Power Scripts using Simple Issue Language and ScriptRunner is using Groovy. Scripts from Power Scripts not compatible with ScriptRunner.
With Power Scripts its much more easy to start, but ScriptRunner is more powerful in some cases.
For this case i rather use Power Scripts then Script Runner, but if you more familiar with groovy then Script Runner will probably be better.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
so we use Script runner, guess i need to start from scratch now, apologies for not highlighting this from the start
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem.
If you get stuck with Script Runner, feel free to raise support request on vendor's service desk.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.