web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Error in patching the records

(1) ShareShare
ReportReport
Posted on by 67

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? 

Categories:
I have the same question (0)
  • EddieE Profile Picture
    4,641 Moderator on at
    Re: Error in patching the records

    @Abdulazizhalawa 

    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.

  • Abdulazizhalawa Profile Picture
    67 on at
    Re: Error in patching the records

    </>

    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 

  • Verified answer
    EddieE Profile Picture
    4,641 Moderator on at
    Re: Error in patching the records

    @Abdulazizhalawa 

    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

    EddieE_0-1686018985145.png

    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
    	)
    )

     

     

     

  • Abdulazizhalawa Profile Picture
    67 on at
    Re: Error in patching the records

    thnaks the the above one solved my problem 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 803 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 314 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 253 Super User 2025 Season 2

Last 30 days Overall leaderboard