Hello guys , I am trying to pacth a record after a value is changed on a gallery my value_id in sql table is ident and yes it's primary key and I am trying to patch the new values as new rows
first: when i dont give it an value_id and says iw was not found
second : when I give a value_id it says it is auto generated
any help?
thnaks the the above one solved my problem
I cannot see any issues with your code. Sometimes after you run the code then get that Network error, your button / icon that holds the code will display a Red 'X' icon in the Editor. If you click on it, usually you will see where the error is coming from in your code. Maybe try this and see what it shows.
Also, to use a code window that I explained above you select it from the icons above your reply window, ie
Then copy your code into the window, ie
Set(prodctIDSelected,SKUsDropDowns.Selected.product_id);
If(
!IsBlank(CurrentValueInput.Text),
If(
(LookUp(clStandardValues, ThisItem.parameter_id = parameter_id)).standard_value <> CurrentValueInput.Text,
Set(LastValueID1,Max(clParameterValues,value_id));
Patch(clParameterValues, Defaults(clParameterValues),
{
parameter_id: LookUp( clParameterValues, parameter_id = ThisItem.parameter_id && product_id= prodctIDSelected).parameter_id,
last_run_value: LookUp(
clParameterValues,
parameter_id = ThisItem.parameter_id && product_id = prodctIDSelected &&
value_id = Max( Filter( clParameterValues, parameter_id = ThisItem.parameter_id, product_id = prodctIDSelected), value_id)
).current_value,
current_value: 15,
Reasons: LookUp( clParameterValues, parameter_id = ThisItem.parameter_id&& product_id= prodctIDSelected).Reasons,
user_id: LookUp( clParameterValues, parameter_id = ThisItem.parameter_id && product_id= prodctIDSelected).user_id,
submit_date: Now(),
product_id: prodctIDSelected
}
)
// I added these brackets below
)
)
</>
Set(prodctIDSelected,SKUsDropDowns.Selected.product_id);
If(
!IsBlank(CurrentValueInput.Text),
If(
(LookUp(
clStandardValues,
ThisItem.parameter_id = parameter_id
)).standard_value <> CurrentValueInput.Text,
Set(LastValueID1,Max(clParameterValues,value_id));
Patch(
clParameterValues,
Defaults(clParameterValues),
{
parameter_id: LookUp(
clParameterValues,
parameter_id = ThisItem.parameter_id && product_id= prodctIDSelected
).parameter_id,
last_run_value:LookUp(
clParameterValues,
parameter_id = ThisItem.parameter_id&&
product_id = prodctIDSelected&&
value_id = Max(
Filter(
clParameterValues,
parameter_id = ThisItem.parameter_id,
product_id = prodctIDSelected
),
value_id
)
).current_value,
current_value: 15,
Reasons: LookUp(
clParameterValues,
parameter_id = ThisItem.parameter_id&& product_id= prodctIDSelected
).Reasons,
user_id: LookUp(
clParameterValues,
parameter_id = ThisItem.parameter_id && product_id= prodctIDSelected
).user_id,
submit_date:Now(),
product_id:prodctIDSelected
});</>
what I am trying to do is if the current_value has changed i will collect what I need to collect then patch it to dat base as new record or row
You are mixing up Creating a New Record and Editing an existing one.
The Default() function is used to Create a new record - you are trying to Edit an existing one so there is no need for this in your code.
Swap
Defaults( ... )
with
LookUp( ... your LookUp function goes here ...)
If you get stuck, post your code into a code window (using </>) and I can help re-write it for you.