Require comment on Due Date change

Ben Bramson February 13, 2018

I have an internal customer that would like to require a comment if the due date for an issue is changed during a transition. I have been trying to use cPrimes Power Scripts to figure it out, but I feel like I'm chasing my tail.

I tried using lastIssueChanges but that seems to only report changes that have already been applied (after the transition is complete). My next thought was that I could use fieldHistory to check what the due date used to be (it will always be set by the time it gets to this point) and compare that with what it is during the transition.  I can't get fieldHistory to report the history for the due date field though, so I'm kinda dead in the water. I've tried using due, dueDate, Due Date, nothing seems to work with fieldHistory(key,history_field_name_or_id)

Any one have any ideas for where I should go from here?

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
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.
February 13, 2018

Try to use hasInput() function in a validator. You can find more info here:

https://confluence.cprime.io/display/SIL/hasInput

Ben Bramson February 13, 2018

Thanks for answering, but when I tried that it always succeeded because there is already a due date. I guess I could do something like ask for a 'New Due Date' but I'm hoping to avoid adding a new field for this.

Alexey Matveev
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.
February 13, 2018

I was able to do it with the following validator script

JFieldChange[] changes = getFieldChanges(key, "duedate");
JFieldChange latestChange = changes[size(changes) - 1];
if (!isNull(latestChange) && dueDate != latestChange.newVal && !hasInput("comment")) {
string errMessage = "enter comment";
return false, errMessage ;
}

return true;
Ben Bramson February 14, 2018

That did it! Very cool! Thanks!

Vladislav Danylenko July 20, 2018

@Alexey Matveev, I want to do the same option. If it possible, can you tell please, where I need to put this script?

Alexey Matveev
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, 2018

Suggest an answer

Log in or Sign up to answer