Forums

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

Set date field based on the field values from drop down field.

Learner AJ March 14, 2023

Hi Team,

we trying to Set the date field is to be set based on the custom field value, like

we need to set a custom field Start Date, based on Processing Period dropdown field value.

The  Start Date field is not in the screens, we want to set this field backend and use later for other automation, so we would like to achieve from JMWE.

The requirement should be like below

  • if Processing Period = 1Q2024, set Start Date = 1 Jan 2024

  • if Processing Period = 2Q2024, set Start Date = 1 Apr 2024

  • and so on…

tried the below script on both Event based postfuctions and postfuctions in workflow.

{% set ProcessingPeriod = issue.fields.customfield_25254 %}
{% set StartDate = issue.fields.customfield_23975 %}

{% if ProcessingPeriod == "1Q2024" %}
{% set date = "Jan 01, 2024" %}
{% set _ = StartDate.setDate(date) %}
{% elif ProcessingPeriod == "2Q2024" %}
{% set date = "Apr 01, 2024" %}
{% set _ = StartDate.setDate(date) %}
{% endif %}

After setting the processing period on transioton there nothing is triggering to set for Target date, no error is displayed.

Can any one please help me on resolving from it.

Thanks,

Beginner,

 

2 answers

2 accepted

1 vote
Answer accepted
David Fischer
Community Champion
March 14, 2023

Hi @Learner AJ 

there are a couple of reasons why your script doesn't work:

  1. I assume the script is used as the value in a Set Issue Fields post function. In that case, the script should return ("output") the value (right now it doesn't output anything)
  2. the expected value format is a date in ISO 8601 format: 2016-08-05. This is visible in the "Expected Value" help tab
  3. To access the value of a dropdown (Single-select custom field), you need to add ".value": issue.fields.customfield_25254.value

Try this script:

{% switch issue.fields.customfield_25254.value %}
{% case "1Q2024" %}
2024-01-01
{% case "2Q2024" %}
2024-04-01
{% endswitch %}
Learner AJ March 15, 2023

Many Thanks @David Fischer 

0 votes
Answer accepted
Learner AJ March 14, 2023

@David Fischer , i trust you are gem in JMWE.

Thanks in advance for your help.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events