Hi,
Below is my requirement,
I have below fields
1.SG1 date (date field)
2.SG2 date (date field)
3.SG3 date (date field)
4. Next Gate (drop down with values 1. SG1 related
2.SG2 related
3.SG3 related
5.Next Gate Due( date field)
Now "Next Gate Due" custom field should automatically copy values from either SG1 date, SG2 date or SG3 date custom fields depending on Next Gate value selected.
Example scenario:
Assume custom fields value are set as below,
SG1 date : 12/8/2015
SG2 date : 12/15/2015
SG3 date : 12/17/2015
Next Gate : SG2 related
Next Gate Due:
Now Next Gate Due custom field should display the date depending on the Next gate custom field value. In above scenario it should automatically display 12/15/2015 as SG2 related value is selected in Next Gate custom field.
How can we achieve this. Is there a script,? if yes please share the script to achieve this.
Thanks in advance,
Nandeesh
Hi Nandeesh,
please, add the following code to your behaviour, associated to "Next Gate" field.
FormField nextgateff = getFieldById(getFieldChanged()) FormField sg1 = getFieldByName("SG1 date") FormField sg2 = getFieldByName("SG2 date") FormField sg3 = getFieldByName("SG3 date") FormField nextGateDue = getFieldByName("Next Gate Due") def nextGateValue = nextgateff.getValue() if(nextGateValue!=null && !"".equals(nextGateValue)){ if(nextGateValue.startsWith("SG1")){ nextGateDue.setFormValue(sg1.getFormValue()) } if(nextGateValue.startsWith("SG2")){ nextGateDue.setFormValue(sg2.getFormValue()) } if(nextGateValue.startsWith("SG3")){ nextGateDue.setFormValue(sg3.getFormValue()) } }
Hope it helps,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nadeeesh, I tried it on my local instance and it worked. Just to be sure, did you add this script to a behaviour associated to your project/issue type and related to Next Gate field? Can you provide me more information about your issue? Regards, Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio, Yes i added this script to a behaviour associated to my project/issue type and related to Next Gate field. Did you try SG1, SG2, SG3 and Next Gate Due with date fields? When i give date in SG1, SG2, SG3 and select any value in Next Gate field, Next Gate Due is not populating any data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nadeesh, yes, I created custom fields with the provided format. Please check custom fields name. In my script SG1 is "SG1 date", SG2 is "SG2 date" and so on. If your custom fields are just SG1, SG2.. please remove date from my script ... ... FormField sg1 = getFieldByName("SG1") FormField sg2 = getFieldByName("SG2") FormField sg3 = getFieldByName("SG3") ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio, in my instance also its same "SG1 Date" and so on. Still not working :( Next Gate Due is not populating any data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nandeesh, please take care about your custom fields name. Script is case sensitive so if you use "SG! Date", script should be : ... FormField sg1 = getFieldByName("SG1 Date") ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fabio, Yes i have taken care of this. Below is the script, Not sure why it is not working :( FormField nextgateff = getFieldById(getFieldChanged()) FormField sg1 = getFieldByName("SG1 Date") FormField sg2 = getFieldByName("SG2 Date") FormField sg3 = getFieldByName("SG3 Date") FormField nextGateDue = getFieldByName("Next Gate Due") def nextGateValue = nextgateff.getValue() if(nextGateValue!=null && !"".equals(nextGateValue)){ if(nextGateValue.startsWith("SG1")){ nextGateDue.setFormValue(sg1.getFormValue()) } if(nextGateValue.startsWith("SG2")){ nextGateDue.setFormValue(sg2.getFormValue()) } if(nextGateValue.startsWith("SG3")){ nextGateDue.setFormValue(sg3.getFormValue()) } }
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.
Hi all,
Can any one help me in this please...
Thanks,
Nandeesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nandeesh
Have you looked at this documentation for ScriptRunner for JIRA?
https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html
In particular there are a set of examples that show you how to calculate values depending on other fields.
Phill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Phill, thanks for the link. But it doesn't help me to meet my requirement. I am not that good at scripting.if you can help me in scripting that would be very helpful for me. :) Many thanks, Nandeesh
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.