Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Automate Post Fungtion set Field value (Date Picker) by JMWE

Hana IT PMO July 20, 2022

Hi Guys,

 

I have fields :

- Start date (Date Picker) 

- End date (Date Picker)

- Additional days Overdue (select list (Single choice)), ex : 3,7,14,21

 

what I need to set "End date" value from post fungtion, if I set "Start date" and "Additional days Overdue".

for exsample : I set "Start date"= 20/07/2022 and "Additional days Overdue"= 7 than post fungtion automate set "End date" value =27/7/2022

 

Please help me, what can I do In post fungtion ( I used Addons JMWE)

 

Regards,

Tyas

2 comments

Comment

Log in or Sign up to comment
Alessandro Lombardo
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.
July 20, 2022

I don't remember very well JMWE but I think you should define the variable startDate maybe in this way:

def startDate = issue.getcustomfieldvalue(Start date)

and then you add days like this:

End date =startDate.plus(Additional days Overdue)

It is not the right code, but the logic should be that. You should have automatic completion with that plugin

Hana IT PMO July 25, 2022

Dear Alessando,

 

Thanks for your respont,

 

Regards,

Tyas

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2022

Hi @Hana IT PMO ,

you can add a Set Issue Fields post-function, configure it to set the End date field, and use this as the value:

{{ issue.fields["Start date"] | date("add", issue.fields["Additional days Overdue"], "days") | date("yyyy-MM-DD") }}
Like Hana IT PMO likes this
Hana IT PMO July 20, 2022

Hi David,

 

the script not work, End date value just copy value from Start date

 

and I try change hange "add" to number (ex:7) and input start date 21-07-2022

{{ issue.fields["Start date"] | date("7", issue.fields["Additional days Overdue"], "Days") | date("yyyy-MM-DD") }} 

the result is 2001-07-01

 

Regards,

Tyas

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2022

Hi Tyas,

The syntax I provided is correct. But you must make sure the field names are exactly as they appear in the Cudtom Fields page. The safest is to use the Issie Fields help tab under the editor to insert a reference to the fields using the field ID instead. 

Also, what is the field type of the Additional days Overdue field?

Hana IT PMO July 20, 2022

Hi David,

 

Additional days Overdue filed type is select list (Single choice) with value 3,7,14,21

 

Regards,

Tyas

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 21, 2022

That explains it - my code assumed the field was a number field.

In that case:

{{ issue.fields["Start date"] | date("add", issue.fields["Additional days Overdue"].value, "days") | date("yyyy-MM-DD") }}

I recommend you use the "Issue Fields" help tab when trying to access an issue field's value.

Like Hana IT PMO likes this
Hana IT PMO July 25, 2022

Dear David,

 

the script work, using your first script

{{ issue.fields["Start date"] | date("add", issue.fields["Additional days Overdue"].value, "days") | date("yyyy-MM-DD") }}

 

second  script not work, it have ".value" 

thanks for your help,

 

Regards,

Tyas 

TAGS
AUG Leaders

Atlassian Community Events