Forums

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

behavior : Cannot capture a date field to be empty

zhangqian04
Contributor
May 13, 2020

I want to set another field to be required according to the change of one date field. When the date field changes from a certain date to null, another field cannot be triggered to be required。

explain:on this date Fields ,implement behavior

code as follows:

def timeField = getFieldById(getFieldChanged())

def formField = getFieldById("comment")

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("执行时间")[0]
def currentDate = (underlyingIssue?.getCustomFieldValue(cf) as Date)?.dateString

if ((timeField?.value as Date)?.dateString != currentDate){
formField.setRequired(true)
}
else
{
formField.setRequired(false)
}


 thanks for your response

2 answers

1 accepted

0 votes
Answer accepted
zhangqian04
Contributor
July 7, 2020

It has been solved by “try”.

0 votes
Zoi Raskou
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.
May 13, 2020

Hi, I might have misunderstood the problem here so I will summarise my understanding. 

When the date field does not have the current date make the comment required, is this right? 

I have created a similar behaviour, all you need is to define that you want the comment field to be required and add your code there. 

I am not sure what the getFieldChanged() does in your script as this will check every field in the screen rather than just the one that has the date?

zhangqian04
Contributor
May 13, 2020

choose the field for the behaviour,  so capture this date time change.

now ,  when date time from a some value to empty value,this script cannnot capture change.

Suggest an answer

Log in or Sign up to answer