Period

The Period component is very similar to the date component. Period is used to display a time period either as a date, time, or datetime with a start and end field to users. The different date types are displayed as options when creating the field, the default display type being date.

When using a display type that allows specifying a time portion, the selected value will be in your machines local time-zone. When saved the value will be converted to UTC and stored in the database. When reading the saved value from the database the value will be converted from UTC into your machines local time-zone.

The following date types are handled by this component:

  • Date
  • Time
  • DateTime
Period Date user control, displaying start and end dates

Component Code

The first section of the code for the component contains the standard parameter set along with the variables needed for the component to function. Following the variables are the methods used by the component which are listed below.

OnParametersSetAsync()

This method is called after the component has initialized and when there’s an update to the parent component. Its purpose is to assign values to variables.

ValueChanged()

This method is called when the value of either of the period fields has changed. This method ensures the field is modifiable and there are no validation errors. If those conditions are met then the ChangeXML method is called, otherwise nothing happens.

ChangeXML()

This method is used to update the XML of the instance to reflect the value of the period field. When called the required XML is generated, the element name is equal to the XMLName variable, and the current value of the field represented as the valueUXStart and valueUXEnd variables. The required XML is generated and saved.

Lastly, a call is made to the ChangeField method on MyInstance and the new XML is passed.

Below is an example of the XML structure to be saved:

<PeriodEx>
    2023-01-10 09:15:23 - 2023-01-22 10:00:00
    <Start>2023-01-10 09:15:23</Start>
    <End>2023-01-22 10:00:00</End>
</PeriodEx>
Updated on December 11, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment