Calculated date from other field

Hi,

I’m developing a simple application where I have two date fields. When I enter a date in the first field the second date field should automatically be set to the value of the first field + 70 days. I’ve tried using the example found on this post, but I haven’t figured it out.

Can anyone please help me?

Best regards,
Pedro

Hi,

Could you please provide more details? For instance, are these date fields connected to a datasource?

Regards,
Gleb

Hi,

Sorry for the lack of details. Yes, the fields are connected to a datasource called Processo. So I have a field called dataCativacao and another one called dataExpiracao on this datasource. When I’m editing the datasource I want to automatically change the value of the field dataExpiracao based on the data entered on the field dataCativacao.

Can you help?

HI,

one solution would be:

  1. Inject the Processo Datasource in the Editor.
  2. Use the “addItemPropertyChangeListener” Method of the Processo Datasource, to automatically change the value of dataExpiracao, after changing the dataCativacao.

Have a look here for information about the Datasource Listeners

Daniel

Hi,

Thanks for the reply. Could you please give me some code examples? I’m new to Cuba and I’m not sure how to do what you suggest. How do I injet the datasource in the editor? I have a generic UI Edit screen for the Processo datasource. Should I put the code in the controller section?

Thanks.

Hi,

Kindly check this one… this will auto calc the man hours when start date & end date is not empty.

The above recommendations are correct (read the doc Datasource Listeners). In order to get more familiar with the platform, I would recommend to watch these webinars: Development Tools Overview and UI development.

Regards,
Gleb