Hi everyone,
I am building a canvas app in which I save data from users' inputs. The contract ID is the key of all, as I use it as a kind of database ID. So, when I entered a new order, first thing the app does is to look for this ID. If it doesn't exist, data is just saved in a new row.This function works perfectly. However, if it exists, I want a column of the data source in which I save quantities, 'Total_Quantity' to be modified by adding up the new number to the previous one. The problem is that I can't find a better solution than this one but it's not only not modifying but also adds a new row. AS you can see I extract the value of the column in the specified record and then try to add it up with the current value. But nothing works.
//Block in which, depending what data is saved if there is a previous order with the same Contract.
If(
//Condition for modifying an existing record
LookUp(
Registry,
Contract = contract.Text,
Contract
) = contract.Text,
Patch(
Registry,
LookUp(
Registry,
Contract = contract.Text
),
{Total_Quantity:(LookUp(Registry,Contract = contract.Text,Total_Quantity))+quantity.Text}
),
//Condition for creating a new record
Patch(
Registry,
Defaults(Registry),
{Contract: contract.Text},
{Date: Text(Date.SelectedDate)},
{Customer: customer.Text},
{Country: Ddwn_country.SelectedText.Value},
{Requested_Date: Text(RequestedDate.SelectedDate)},
{Condition: Ddwn_condition.SelectedText.Value},
{Total_Quantity: quantity.Text}
)
)
Thanks beforehand