Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add a custom field to a Date

TILLENAYAGANE December 12, 2024

Hi everybody,

I need your help please. I am beginner about JIRA

That I wanted :
I have two custom fields : 

1) "Date de MEP" as a date (customfield_14329)

2) "Délai avant fin" as alphanumeric (customfield_16609) but this field has only numbers 

With Autonomation, I want to substract "Délai avant fin" to "Date de MEP" and put the result in "Actual End" when "Délai avant fin" is changed
I try but doesn't work :

{{issue.customfield_14329.minusDays(("Durée de l'action").asNumber)}}

{{issue.customfield_14329.minusDays(issue.customfield_16609)}}

but

{{issue.customfield_14329.minusDays(3)}} : it's works with 3 but with doesn't work with a custom fields

Can you help me please ? Thank you very much

1 answer

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2024

Hi @TILLENAYAGANE -- Welcome to the Atlassian Community!

In your first expression, the asNumber conversion is at the wrong location.  It should be convert the text field to a number for use as a parameter:

{{issue.customfield_14329.minusDays(issue.customfield_16609.asNumber)}}

 

Kind regards,
Bill

TILLENAYAGANE December 12, 2024

thanks for your help, but it's doesn't work.

Capture d’écran 2024-12-12 171114.png

TILLENAYAGANE December 12, 2024

Capture d’écran 2024-12-12 171226.png

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2024

First thing, for rules like this where conversion is involved, it helps to use writes to the audit log to check the values: https://confluence.atlassian.com/automation/jira-automation-actions-993924834.html#Jiraautomationactions-logactionLogaction

I recommend adding some writes to the audit log to help diagnose this during testing:

customfield_14329: {{issue.customfield_14329}}

customfield_16609: {{issue.customfield_16609}}

customfield_16609.asNumber: {{issue.customfield_16609.asNumber}}

 

Next, I found a defect indicating asNumber does not always work with text fields converted to numbers when used in a function callhttps://jira.atlassian.com/browse/JIRAAUTOSERVER-1084

Based on another workaround I recall for Jira Data Center, let's try forcing the field to text first and then to a number:

{{issue.customfield_14329.minusDays(issue.customfield_16609.trim().asNumber)}}

 

TILLENAYAGANE December 13, 2024

Hi,


It's very usefull the audit log (I didn't know before). Thanks a lot


customfield_14329: 2024-12-17T19:45:00.0+0000  (it's my date)

customfield_16609: 9  (it's my alphanumeric custom fields)

 but : 

"customfield_16609.asNumber" or  "issue.customfield_16609.trim().asNumber :" no result

 

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 13, 2024

That result implies customfield_16609 is a number field, and not a text field.

Are you certain you tried this expression using it as a number:

{{issue.customfield_14329.minusDays(issue.customfield_16609)}}

 

Are you certain customfield_14329 is a date (or date / time) picker field?  If not, let's try this to convert from a text-based date to a date type first:

{{issue.customfield_14329.toDate.minusDays(issue.customfield_16609)}}

I also know that some date fields are treated as text when they reach an automation rule's smart values, and so the toDate conversion is needed.

 

TILLENAYAGANE December 17, 2024

Hello,

I am sure... but doesn't work : no results for this 2 :

{{issue.customfield_14329.toDate.minusDays(issue.customfield_16609)}}{{issue.customfield_14329.minusDays(issue.customfield_16609)}}

 but when i put a number it's work : {{issue.customfield_14329.minusDays(3)}}

with log

Capture d’écran 2024-12-17 165110.png

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2024

Thanks for testing, and it appears the defect I noted earlier also applies to the date / time functions.  You could confirm that by contacting the Atlassian Support team for their input.

TILLENAYAGANE December 18, 2024

OK thanks a lot.  I will try with a another type of column.

Suggest an answer

Log in or Sign up to answer