Hi, I need to have a calculated field that will:
Take the date from Field A and minus the value from Field B
Write the outcome date to Field C
is it possible?
Hi @Javanshir Mustafayev _ HIT ,
what is field B supposed to represent? A number of days, hours, seconds, ...?
Also, where are you trying to use that calculation? A Set Issue Fields post-function?
Hi @David Fischer Field B is a number field, that represents days. And is to be used to minus it's value from Field A which is a date picker field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then the Nunjucks expression you're looking for is:
{{issue.fields["A"] | date('subtract', issue.fields["B"] , "days") | date }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Fischer thanks for your help, the script above works, but could you please help me trim the value
from:
2031-07-28T00:00:00+00:00
to:
2031-07-28
?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, if I remove either Field A or Field B values, I wish the Field C to be cleared and be empty, if possible, please
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Javanshir Mustafayev _ HIT if you are writing this value to a Date Picker field, the value will be "trimmed" automatically by Jira.
As for returning an empty value when one of the source fields is empty, you can do this:
{% if issue.fields["A"] and issue.fields["B"] %}
{{issue.fields["A"] | date('subtract', issue.fields["B"] , "days") | date }}
{%endif%}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Fischer the values aren't removed if any of the fields is emptied. The read-only field stays untouched with the previously calculated value.
Also, Jira isn't trimming because I'm using a read-only text field, is there a workaround or the field should be a date field to be trimmed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Fischer I've changed the field type to a date picker, and hid it on the screen configs, now all works as expected, thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FYI, you cannot clear a read-only text field, it's a Jira Cloud limitation.
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.