DINAMIC CHANGE INPUT DATE WITH 2 VARIABLES

Hello, guys!

(Outsystems 11.7.6 Version)

I'm developing a responsive web application and I'm having difficulties with an input box (Expiration_date) that contains date to be changed automatically based on 2 variables. The first variable is an input box (Date_Contract) with date and the second is a dropdown (Type) where I select the type of contract that contains the monthly, semi-annual and annual options. If I choose the annual option, Expiation_date will return Date_Contract plus 12 months. Using AddMonths (GetSaleById.List.Current.Sale.Date_Contract, 12) I got it to work, but when I try to put one more "Type" variable I was not successful. The number 12 would be the return of the "Period" column of the "Type" table when choosing the "Annual" option.


Tables

1) Sale: Columns

    Id, Date_Contract, Type, Expiration_Date


2) Type: Columns

    Id, Type (Text) , Period (Integer)


 




Hi Jesus,

Did you try something like this  AddMonths (GetSaleById.List.Current.Sale.Date_Contract, GetType(<variable of Type combobox>).Period)

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi Jesus,

Did you try something like this  AddMonths (GetSaleById.List.Current.Sale.Date_Contract, GetType(<variable of Type combobox>).Period)

Regards,

Marcelo

Hi Marcelo,

I've tried it and it works if I don't change the "Type" option. For example, if I change the form, the option "Type" to semiannual, the calculation is not updating automatically keeping the first calculation.


SyntaxEditor Code Snippet

AddMonths(GetSaleById.List.Current.Sale.Date_Contract,GetType.List.Current.Type.Period)


Hi,

GetType.List is the list of all the types and basically you are using the first one of that list. And the current of a list doesnt change unless you do something with it. But you don't want to use the list. You want to use the variable where is saved the selection of the user. You can find that variable on the dropdown properties. Look for the property variable. You should have assign a variable there and you should us that one like I said:

GetType(<variable of Type dropdown>).Period

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi,

GetType.List is the list of all the types and basically you are using the first one of that list. And the current of a list doesnt change unless you do something with it. But you don't want to use the list. You want to use the variable where is saved the selection of the user. You can find that variable on the dropdown properties. Look for the property variable. You should have assign a variable there and you should us that one like I said:

GetType(<variable of Type dropdown>).Period

Regards,

Marcelo

Sorry, Marcelo, but I'm a beginner and I still can't understand it. In the "Type" dropdown, a GetList exists as a variable. Would I have to create a local variable to assign the Period value? And put it in the Attributes Property area as "Class"?


Hi,

No problem. We are here to help you. The variable I was talking about is "GetSaleById.List.Current.Sale.Type". Since you chose this as the variable of dropdown here will be saved the Type.Id (because you choose it as the value) of the option the user chooses. This means you can use this id to get the record by using "GetType(GetSaleById.List.Current.Sale.Type)" and get the period value. In the end you should have something like this:

You can use something like this AddMonths (GetSaleById.List.Current.Sale.Date_Contract, GetType(GetSaleById.List.Current.Sale.Type).Period)

Regards,

Marcelo

Marcelo Ferreira wrote:

Hi,

No problem. We are here to help you. The variable I was talking about is "GetSaleById.List.Current.Sale.Type". Since you chose this as the variable of dropdown here will be saved the Type.Id (because you choose it as the value) of the option the user chooses. This means you can use this id to get the record by using "GetType(GetSaleById.List.Current.Sale.Type)" and get the period value. In the end you should have something like this:

You can use something like this AddMonths (GetSaleById.List.Current.Sale.Date_Contract, GetType(GetSaleById.List.Current.Sale.Type).Period)

Regards,

Marcelo

Marcelo, the variable are not accepting this expression. Even if I take ".", It still gives an error.



Hi,

That part was correct and you should keep GetSaleById.List.Current.Sale.Type. The part where you are using the addmonths is what you need to change to : AddMonths (GetSaleById.List.Current.Sale.Date_Contract, GetType(GetSaleById.List.Current.Sale.Type).Period)

Marcelo Ferreira wrote:

Oi,

Essa parte estava correta e você deve manter GetSaleById.List.Current.Sale.Type. A parte em que você está usando os addmonths é o que você precisa mudar para: AddMonths (GetSaleById.List.Current.Sale.Date_Contract, GetType (GetSaleById.List.Current.Sale.Type) .Period)

Marcelo,

He didn't recognize that expression, either.


Hi,

Sry forgot you are in reactive. And in this case is a bit more tricky since you need to get the static record.

In attachment a possible solution.

Regards,

Marcelo