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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to fetch and compare previous value and new value of Due Date field

Hi everyone, I am new to Jira and stuck with a task

I need to read previously entered value and newly/update  entered value in Due Date and compare both of them and

1. Ask user to enter the reason of change due date in text box

2. Send alert notification to PM on Due Date Change  as user updates the issue in JIRA.

 

Any help would be greatly appreciated.  

3 answers

1 accepted

0 votes
Answer accepted

Hi Anupam,

I can confirm that it is possible to achieve your requirement with ScriptRunner for Jira Cloud by creating a Script Listener that is configured on the Issue Updated event. 

The script for the listener would then be able to get the changelog property which contains details of what fields changed when the issue was updated.

You would then be able to check against this property if the Due Date field changed and if it did to save the old and new values for these fields to variables in your script.

You would then be able to call to the Send a notification for an issue API which Atlassian provides in order to send a notification explaining how the Due Date field changed.

I can confirm we have an example script located in the documentation page located here which shows how to check the changelog property and to send a notification when the priority on an issue changes.

You will be able to take this script and use it as a reference guide to help you to create the script that you require to achieve your requirements.

As for your requirement of checking what the user enters on the screen then you can do this using a Workflow Validator  and this page gives some examples as well explains how to add a new validator to your workflow.

Also, we have a Knowledge Base Article here which explains the strategy that should be used to determine how to create the validator expression which you require but it would be similar to the expressions other users have given above.

I hope this information helps.

Regards,

Kristian

Thank you so much Kristian for kind help and useful tips. 

Hi @Anupam Sinha ,

To force the user to enter a comment describing the reason for the Due Date change, you can add a JMWE Build-your-own Validator with the following script:

originalIssue.dueDate == issue.dueDate || issue.comments.some(it => !it.id)

 And you'll enter an error message like: "You must describe, in a comment, the reason for te Due Date change"

As for notifying the PM, you could use a JMWE Email Issue post-function, configuring it to notify the members of the "PM" project role, and using Conditional Execution to send the email only if the Due Date field was modifying during the transition. This can be done using this conditional execution script:

{%set lastDueDateChange = issue | fieldHistory( "duedate" ) | last %}
{{ not lastDueDateChange or (lastDueDateChange.date | date | date("diff", nowObj, "s" ) > -10)}}

Thank you David for looking into it. Currently, I am trying to automate the workflow with Scriptrunner. I will also try with JMWE 

0 votes
John Funk Community Leader Jan 19, 2021

Hi Anupam - Welcome to the Atlassian Community!

The only think I know to do in this scenario is to create another custom field and set it equal to the value of the Due Date when it is created or first populated. Then when it is changed, you can compare the new Due Date to the value in the custom field using JMWE or ScriptRunner.

Thank you John. Constraint is : Client does not want to add another custom field. With the additional custom field  it is bit challenging. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in New to Jira

Check out the ✨NEW✨ Group for Jira Cloud Admins

Hello Community members!  Wanted to give you the heads up about a NEW Community Group for Jira Cloud Admins.  This is a group where you can ask questions, access resources, and rub elb...

88 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you