Requriement
1) Add 10 days to custom date field.
2) 10 days will be pulled from a custom field ( number)
Tried
Below step using behavior plugin but not working
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*
def desc = getFieldById("customfield_11002")
def defaultValue = getFieldById("customfield_11003")
def newvalue = defaultValue.getFormValue() as Long
desc.setFormValue(newvalue)
return
I am not able to access the value of customfield_11003 to store in customfield_11002
Not interested in using misc custom fields as it is messing up with my custom field view
Hi Armar,
For the searcher use the Date Time Range picker. For the template use Date Time Picker.
And in the inline field add the logic. In your case should be something like:
def dateField = getCustomFieldValue("DateCF") def numberField = getCustomFieldValue("NumberCF") def number = numberField?.intValue() if (number == null || dateField == null) return def result = dateField + number return new Date(result.getTime())
Please let me know if this works for you.
Regards,
Thanos
Amar, As I said, the solution I propose is to use scripted field (https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html) and not a behaviour. As far as I understand you want a custom field which will hold the value of two other custom fields (in your case a date plus a number).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You don't have to import anything in the above script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml [onresolve.scriptrunner.customfield.GroovyCustomField] getCustomFieldValue called from script: No field with ID or name customfield_10620 /sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml [onresolve.scriptrunner.customfield.GroovyCustomField] getCustomFieldValue called from script: No field with ID or name customfield_11106
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Apparently there are no custom fields assigned to you project with such names. Please try to add as a param in getCustomFieldValue the name and no the id of the custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you mean def dateField = getCustomFieldValue("Planned date") def numberField = getCustomFieldValue("Number of days") def number = numberField?.intValue() if (!number || !dateField) return def result = dateField + number return new Date(result.getTime()) instead of def dateField = getCustomFieldValue("customfield_11111") def numberField = getCustomFieldValue("customfield_11234") def number = numberField?.intValue() if (!number || !dateField) return def result = dateField + number return new Date(result.getTime())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suppose the logic should be something like that (in pseudocode): while (i < number) { dateField ++ if (dateField == sunday || dateField == saturday) i -- i ++ }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanus. /*import com.atlassian.jira.issue.MutableIssue import java.sql.Timestamp; MutableIssue myIssue = issue; def dateField = getCustomfieldValue("Date") Calendar dateField = Calendar.getInstance() def numberfield = getcustomFieldValue("Days") def number = numberfield?.intValue() if number (!number || !dateField) return dateField.add(Calendar.DATE, number) while ([Calendar.SATURDAY, Calendar.SUNDAY].contains(dateField.get(Calendar.DAY_OF_WEEK))) { def dateField.add(Calendar.DATE,number) } def result = new Timestamp(dateField.gettime()) return new Date(result.gettime())*/ Not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanos, Is it possible to add the date and number and get a output.. If yes please let me know which import option I need to choose Regards Amar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Amar, You can have a look at https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html I think a scripted field that depends on the result of 2 other custom fields is what you want. Please let me know if you need any help with the script part Cheers Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos, I want to use 1 custom date field value and add it with 2nd custom number field content and populate result into 3rd custom field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amar, Could you please be more specific in what you are trying to achieve, maybe using a scripted field (if you are using script runner) ? What type are your custom fields ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried using the JIRA Workflow Toolbox plugin and using the Post Function Math & Date-Time Expression Calculator
I think that will do exactly what you are looking for.
In the Post Function you can use something like
datePart({Customfield_ID(Date)}, LOCAL) + ({CustomField_ID(Number)} * {DAY})
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.