How to clear value of DateRange in SME computation rules

I have Field type of DateRange, I would like to empty / clear the value in some condition (FieldFilled).
How can I do that?
Thanks

Hi @luu-far-shell,
I do not know what your specific expectation is but I would use data configuration feature in the form model.

Let’s say we have a dateRange field and an enumeration field with values a,b,c.
In Form Model you need to open the “data configuration” tab and on dateRange field you can configure the behavior as in the image below:


This set-up will lead to the follwing behavior:

  • if “a” is selected in the enumeration field, the dateRange is hidden altogether and will be cleared upon save
  • if “b” is selected in the enumeration field, the dateRange field input is replaced with empty value (dateRange is changed to null)
  • if “c” is selected in the enumeration field, no adjustment to the dateRange field should happen and the dateRange is visible

Let me know if that helps your case. If not, please, give me more details about your specific modeling set-up so that I/we can provide more specific answer.

Hi @luu-far-shell

As @katerina-icy-token says, having a few more details on your models and use-case would be useful. That being said, I have a couple of further points that might interest you.

  1. Computation Rules will clear fields if no precondition matches.

If you model a Computation Rule so that no precondition matches your “condition (FieldFilled)” then the Field will be cleared.

You will however run into problems with this approach as it is not possible to compute a DateRange. This means you can never correctly compute the state where your DateRange Field is filled and therefore your document will be invalid.

In addition, there is a bug in the 2023.06 release line which means that this clearing of the field will only happen in the front end, A12-16238. This has been fixed in 2024.06-ext2

  1. Not Relevant Dependencies were brought in 2024.06

In 2023.06 you can still use a “Clear” Dependency. However, I would not recommend this as a long term solution as this option was replaced by the Not Relevant Dependency that @katerina-icy-token showed.

Here are some 2023.06-ext6 models for you to test.
ClearDateRange_DM.json (4.2 KB)
ClearDateRange_FM.json (2.7 KB)

So, can you give us any more details to help you find a solution?

  • Where is the data for this Data Range coming from?
  • When and where should the data be cleared (frontend / backend)?
  • What is the other condition in this Computation Rule?

Thank @katerina-icy-token and @malcolm-silver-ice,
Data configuration is exactly what I need.
Here, DateRange field MemberAvailabilityDates depends on MemberActive with following rules:

read only and clear if MemberActive == false

So this is not computation rules but data configuration feature for someone to look for.
Marked as resolved!
Thank everyone :smiley: