/
[data management] Unable to clear date fields programmatically [5.2.2-B2]

[data management] Unable to clear date fields programmatically [5.2.2-B2]

In-Portal uses the database to store the data and HTML to display it. In some cases (e.g., dates, credit card expiration, weight), the user sees a formatted value (e.g. “07/17/2024 2:20 PM“) instead of a database value (e.g. “1721215210“).

Below is the sample PHP code to demonstrate the formatter-powered value update in the database:

// ✅ Set the date using separate date/time virtural fields: $object->SetDBField('FieldName_date', 1721215210); $object->SetDBField('FieldName_time', 1721215210); $object->Update(); // The 'FieldName' field now has combined value of _date/_time fields. // ✅ Set the date using the database field/_combined virtual field: $object->SetDBField('FieldName', 1721215210); $object->SetDBField('FieldName_combined', 1); $object->Update(); // The _date/_time fields aren't used. // ❌ Set the date using the database field only: $object->SetDBField('FieldName', 1721215210); $object->UpdateFormattersSubFields(array('FieldName')); $object->Update(); // The _date/_time fields are set from the 'FieldName' field.

All solutions work when setting a non-empty value. However, the solutions marked with the ❌ sign don’t allow for clearing the field's existing value.

Solution

Update the “\kDateFormatter::UpdateSubFields” method to support empty values.

Related Tasks

https://in-portal.atlassian.net/browse/INP-1886