Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Date

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

date
Expand
titleForms
Code Block
languagegroovy
themeMidnight
linenumbersfalse
def formFieldSet = api.createConfiguratorEntry()

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

return formFieldSet
Expand
titleIn input generation mode (syntax check mode)
Code Block
languagegroovy
themeMidnight
linenumbersfalse
api.inputBuilderFactory()
        .createDateUserEntry('date')
        .getInput()
Expand
titleIn header Logics
Code Block
languagegroovy
themeMidnight
linenumbersfalse
processor.addOrUpdateInput(                 //❶
        'ROOT',
        api.inputBuilderFactory()
                .createDateUserEntry('date')
                .buildMap()
)

❶ the processor can be one of the quoteProcessor, cProcessor, etc., which references subclasses of the CalculableLineItemCollectionBuilder

Code Block
languagegroovy
themeMidnight
titleReading input value in a line-item logic.
linenumbersfalse
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
Expand
titleForms
Code Block
languagegroovy
themeMidnight
linenumbersfalse
def formFieldSet = api.createConfiguratorEntry()

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

return formFieldSet
Expand
titleIn input generation mode (syntax check mode)
Code Block
languagegroovy
themeMidnight
linenumbersfalse
api.inputBuilderFactory()
        .createTimeUserEntry('time', )
        .getInput()
Expand
titleIn header Logics
Code Block
languagegroovy
themeMidnight
linenumbersfalse
processor.addOrUpdateInput(                 //❶
        'ROOT',
        api.inputBuilderFactory()
                .createTimeUserEntry('time')
                .buildMap()
)

❶ the processor can be one of the quoteProcessor, cProcessor, etc., which references subclasses of the CalculableLineItemCollectionBuilder

Code Block
languagegroovy
themeMidnight
titleReading input value in a line-item logic.
linenumbersfalse
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
Expand
titleForms
Code Block
languagegroovy
themeMidnight
linenumbersfalse
def formFieldSet = api.createConfiguratorEntry()

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

return formFieldSet
Expand
titleIn input generation mode (syntax check mode)
Code Block
languagegroovy
themeMidnight
linenumbersfalse
api.inputBuilderFactory()
        .createDateTimeUserEntry('dateTime', , )
        .getInput()
Expand
titleIn header Logics
Code Block
languagegroovy
themeMidnight
linenumbersfalse
processor.addOrUpdateInput(                 //❶
        'ROOT',
        api.inputBuilderFactory()
                .createDateTimeUserEntry('dateTime')
                .buildMap()
)

❶ the processor can be one of the quoteProcessor, cProcessor, etc., which references subclasses of the CalculableLineItemCollectionBuilder

Code Block
languagegroovy
themeMidnight
titleReading input value in a line-item logic.
linenumbersfalse
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
Expand
titleForms
Code Block
languagegroovy
themeMidnight
linenumbersfalse
def formFieldSet = api.createConfiguratorEntry()

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

return formFieldSet
Expand
titleIn input generation mode (syntax check mode)
Code Block
languagegroovy
themeMidnight
linenumbersfalse
api.inputBuilderFactory()
        .createDateRangeUserEntry('dateRange', , , )
        .getInput()
Expand
titleIn header Logics
Code Block
languagegroovy
themeMidnight
linenumbersfalse
processor.addOrUpdateInput(                 //❶
        'ROOT',
        api.inputBuilderFactory()
                .createDateRangeUserEntry('dateRange')
                .buildMap()
)

❶ the processor can be one of the quoteProcessor, cProcessor, etc., which references subclasses of the CalculableLineItemCollectionBuilder

Code Block
languagegroovy
themeMidnight
titleReading input value in a line-item logic.
linenumbersfalse
final datePattern = 'yyyy-MM-dd'
def dateFrom = api.parseDate(datePattern, input.dateRange[0])
def dateTo = api.parseDate(datePattern, input.dateRange[1])

...