Hint: Date Picker component and input onChange event.
Question

Hi all,

I found the curiously bug: input vs Date Picker doesn't work as expected.

Short description: I've added to the screen input with local variable and Date Picker pattern from WebUI assigned to this input.

Attempt 1. Simple:

When I choose date, I see that input value is changed. I expect, that input variable will be also changed, but this is not happening, because there is no AJAX request to the server

Well, then attempt 2. A little harder:

I've added onChange event handler action for input. In this action I assing to local variable the new value of input. But again without positive result: local variable doesn't change.

Attempt 3. The right one:

I found that Date Picker pattern have event onSelect. If I assign selected date to local variable in this event handler, all works fine.

Why I wrote this all? This behavior is not what I expect. In 2nd attempt I see, that input value changes in UI, and I expect that onChange event should handle it and send the new data to the server. This event works fine with input without Date Picker pattern, but doesn't work with this pattern.

I hope that my small research will help someone.

BR

Evgeny

mvp_badge
MVP

Hello Evgeny, 

A question (I can't test this right now). 

When you did your second test, did you actually Used the variable in any place? 

First thing is that variables are updated only when submitting to the server, which happens only if you explicitly have something set to do it, like an OnChange or OnClick or do it through a button/link

Second thing is that every time you submit to a Screen Action (submit or Ajax submit) , the variables bound to inputs are automatically updated if the values are correct (data type and format) and if you are using the variable somewhere in the page, and the platform detects that change the variable value will have impact in the page. 

On any other case, the variable will not be updated. Than my question, as I am expecting your 2° test to also work without the need to assign a value to the variable. 

Cheers. 

Eduardo Jauch wrote:

Hello Evgeny, 

A question (I can't test this right now). 

When you did your second test, did you actually Used the variable in any place? 

First thing is that variables are updated only when submitting to the server, which happens only if you explicitly have something set to do it, like an OnChange or OnClick or do it through a button/link

Second thing is that every time you submit to a Screen Action (submit or Ajax submit) , the variables bound to inputs are automatically updated if the values are correct (data type and format) and if you are using the variable somewhere in the page, and the platform detects that change the variable value will have impact in the page. 

On any other case, the variable will not be updated. Than my question, as I am expecting your 2° test to also work without the need to assign a value to the variable. 

Cheers. 

Hello Eduardo, 

the sceleton is - input, Date Picker, local variable, expression bound to local variable.

When I'm using onChange input event, the expression on the page doesn't changes. And yes, I do not forgot Ajax Refresh of this expression

Hi, i found also some drawback when using format for the widget, and i turn to other component:

Hi Evgeny,

I wanted to implement your tip in a React App, in the following use case.

I've a Datefield with datepicker. When user selects a date (e.g. 01-10-2021):

Step 1: the selected date has also to be assigned to another field which is not changeable by user. 

Step 2: in this field the selected date has to be shown as DDMMYY, e.g. 011021. 

(And when user selects a different date again, this field has to be updated again)

But I didn't manage to realize step 1. Hopefully you can give more explanation.

Thx in advance. 

Jay

Step 1 I've managed. The field gives now the same input as the user has filled in (e.g. 01-10-2021).

But when using expression editor (using FormatDateTime, or DDMMYY) on the field gives not the desired result 011021.

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