Set Display field based on date range

HP8
Giga Guru

Hi team. I'm trying to make a field display when a case record was created before 30/09/2023, however I'm having trouble trying to get it work. I'm not sure whether the date format and gliderecord to call the date is correct or not. Please note that our date format is dd mm yyyy

 

 

	var createdDate = g_form.getSysCreatedOn();
	var thresholdDate = new Date('30-09-2023');

        if (g_form.getdisplaybox('account').value != 'ABC') {
	if (createdDate < thresholdDate) {
		g_form.setDisplay('u_fieldname', true);
		} else {
		g_form.setDisplay('u_fieldname', false);
	
}
	}

 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

I would recommend using a UI Policy for this and then evaluating the date through the condition on the UI Policy, then in the UI Policy actions related list, select the field and choose "Visible" = true. This is a no-code and easy to implement solution and should always be done, if you can, before using a client script.

AllenAndreas_0-1696812175224.png

I see you're evaluating another field as well, you can also do that in the UI Policy much like the date evaluation I show in the screenshot above.

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

1 REPLY 1

Allen Andreas
Administrator
Administrator

Hi,

I would recommend using a UI Policy for this and then evaluating the date through the condition on the UI Policy, then in the UI Policy actions related list, select the field and choose "Visible" = true. This is a no-code and easy to implement solution and should always be done, if you can, before using a client script.

AllenAndreas_0-1696812175224.png

I see you're evaluating another field as well, you can also do that in the UI Policy much like the date evaluation I show in the screenshot above.

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!