Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 76 Next »

The date and time inputs provide a simple way for end-users to pick values from a fixed set.

Date

To create an input for selecting a time, use the date input:

date
 Forms
def formFieldSet = api.createConfiguratorEntry()

formFieldSet.inputs = [
    api.inputBuilderFactory()
        .createDateUserEntry('date')
        .buildContextParameter()
]

return formFieldSet
 In input generation mode (syntax check mode)
api.inputBuilderFactory()
        .createDateUserEntry('date')
        .getInput()
 In header Logics
processor.addOrUpdateInput(
        'ROOT',
        api.inputBuilderFactory()
                .createDateUserEntry('date')
                .buildMap()
)
Reading input value in a line-item logic.
final datePattern = 'yyyy-MM-dd'
def date = api.parseDate(datePattern, input.date)

Time

To create an input for selecting a time, use the time input:

time
 Forms
def formFieldSet = api.createConfiguratorEntry()

formFieldSet.inputs = [
    api.inputBuilderFactory()
        .createTimeUserEntry('time')
        .buildContextParameter()
]

return formFieldSet
 In input generation mode (syntax check mode)
api.inputBuilderFactory()
        .createTimeUserEntry('time', )
        .getInput()
 In header Logics
processor.addOrUpdateInput(
        'ROOT',
        api.inputBuilderFactory()
                .createTimeUserEntry('time')
                .buildMap()
)
Reading input value in a line-item logic.
def matcher = input.time =~ /(?<hour>[0-9]{2}):(?<minute>[0-9]{2})/
matcher.matches() // ❶
def hour = matcher.group('hour') as Integer
def minute = matcher.group('minute') as Integer

❶ You need to test if pattern matches before you can extract groups by name.

Date Time

To create an input for selecting a combination of date and time, use the date-time input:

date time
 Forms
def formFieldSet = api.createConfiguratorEntry()

formFieldSet.inputs = [
    api.inputBuilderFactory()
        .createDateTimeUserEntry('dateTime')
        .buildContextParameter()
]

return formFieldSet
 In input generation mode (syntax check mode)
api.inputBuilderFactory()
        .createDateTimeUserEntry('dateTime', , )
        .getInput()
 In header Logics
processor.addOrUpdateInput(
        'ROOT',
        api.inputBuilderFactory()
                .createDateTimeUserEntry('dateTime')
                .buildMap()
)
Reading input value in a line-item logic.
final dateTimePattern =  "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
def dateTime = api.parseDateTime(dateTimePattern, input.dateTime)

Date Range

To create an input for selecting a pair of dates — a date range — use the date range input:

date range
 Forms
def formFieldSet = api.createConfiguratorEntry()

formFieldSet.inputs = [
    api.inputBuilderFactory()
        .createDateRangeUserEntry('dateRange')
        .buildContextParameter()
]

return formFieldSet
 In input generation mode (syntax check mode)
api.inputBuilderFactory()
        .createDateRangeUserEntry('dateRange', , , )
        .getInput()
 In header Logics
processor.addOrUpdateInput(
        'ROOT',
        api.inputBuilderFactory()
                .createDateRangeUserEntry('dateRange')
                .buildMap()
)
Reading input value in a line-item logic.
final datePattern = 'yyyy-MM-dd'
def dateFrom = api.parseDate(datePattern, input.dateRange[0])
def dateTo = api.parseDate(datePattern, input.dateRange[1])

Minimum and Maximum Values

You can restrict the input from the user, by setting minimum and maximum dates.

As of version 7.3, the functionality for setting the minimum and maximum values hasn’t been implemented in the frontend application. However, you can still set these properties in a Groovy logic.
String dateFormat = "yyyy-MM-dd"
Date minDate = api.parseDate(dateFormat, "2021-01-15")
Date maxDate = api.parseDate(dateFormat, "2021-01-25")

api.inputBuilderFactory()
    .createDateUserEntry('Date')
    .setMin(minDate)
    .setMax(maxDate)
    .getInput()
  • No labels