Add a custom field to a Date

TILLENAYAGANE
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 12, 2024

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

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

TILLENAYAGANE
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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

 

Suggest an answer

Log in or Sign up to answer