36
Views
4
Comments
Solved
[OutSystems UI] Set InitialMonth to current month in Month Picker component
outsystems-ui
Reactive icon
Forge component by Gonçalo Martins
Application Type
Reactive

Hello,

I am grappling with a seemingly straightforward issue. I am utilizing the Month Picker component from Outsystems UI, but I cannot figure out how to set the initial month to the current month.

The InitialMonth variable is of the MonthYear type, and when I expand it, the Month variable appears to have a Month Identifier type. I presume this type expects the full name of the month, which means that using something like Month(CurrDate()) would not work.

I came across a discussion where it was mentioned that this issue was resolved in OS UI 2.13 (ROU-3951). I am currently using version 2.16, however, the release notes for that fix indicate an improvement to the Month Picker component such that it returns the month order when the OnSelect event is activated, which doesn't seem to address the original issue raised in the topic I referred to.

Has anyone managed to find a solution to this?

Solution

Hi @Andrea Caselli ,

That option wasn’t added on the Input Parameter’s for two reasons:

  • Avoid soft Platform breaking-changes
  • And because the default month is based on the current date, so this use-case would be unblocked, by managing the input's binded Date variable.

That being said, I attached an oml with two solutions. One using a more low-code approach and another one using the Initialized event of the MonthPicker, with the OutSystems UI JS API.


Let me know if it helped!


Best regards,

Bernardo Cardoso

PickerCurrentMonth.oml

Hey Andrea,

You have to follow the below steps

1)create one value called currentMonth of type Month Identifier

2)Create onInitialize and use the switch like below image and assign the months

3)use the currentMonth Varible in your month


It will work!

Thanks & Regards,

Sudip Pal

Hi @Sudip Pal ,

Thank you for your guidance!

I had considered this approach, albeit as a last resort. It strikes me as quite cumbersome – is this genuinely the only method to accomplish this?

I'm contemplating proposing a new "Idea": a built-in function named "Month" that would yield an output of the "Month Identifier" type. This could potentially streamline the process considerably.

Solution

Hi @Andrea Caselli ,

That option wasn’t added on the Input Parameter’s for two reasons:

  • Avoid soft Platform breaking-changes
  • And because the default month is based on the current date, so this use-case would be unblocked, by managing the input's binded Date variable.

That being said, I attached an oml with two solutions. One using a more low-code approach and another one using the Initialized event of the MonthPicker, with the OutSystems UI JS API.


Let me know if it helped!


Best regards,

Bernardo Cardoso

PickerCurrentMonth.oml

Hey @Andrea Caselli ,

Use the following code in place of month :

If(Month(CurrDate())=1,Entities.Month.January,If(Month(CurrDate())=2,Entities.Month.February,If(Month(CurrDate())=3,Entities.Month.March,If(Month(CurrDate())=4,Entities.Month.April,If(Month(CurrDate())=5,Entities.Month.May,If(Month(CurrDate())=6,Entities.Month.June,If(Month(CurrDate())=7,Entities.Month.July,If(Month(CurrDate())=8,Entities.Month.August,If(Month(CurrDate())=9,Entities.Month.September,If(Month(CurrDate())=10,Entities.Month.October,If(Month(CurrDate())=11,Entities.Month.November,Entities.Month.December)))))))))))



It will definitely work!!!

Thanks & Regards,

Sudip Pal

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.