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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch a Collection to ...
Power Apps
Answered

Patch a Collection to sql server not working

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

For some reason, I can't get the following code to update sql server  ?

 

I have no error on the button ?

 

 

ForAll(colFilterAmendDataStart,Patch(t_redbook_pricing_escalation_detail_Amend,Defaults(t_redbook_pricing_escalation_detail_Amend),

{ RBP_MASTER_ID: Value(AUTO_ID),
PRICING_ESCALATION_ID: Value(RBK_EscalationId_txt.Text),
SKU: SKU,
QTY: Value(QTY),
PRODUCT_DESCRIPTION: PRODUCT_DESCRIPTION,
TARGET_PRICE: Value(TARGET_PRICE),
TARGET_GP: Value(TARGET_GP),
UPDATED_TARGET_PRICE: Value(UPDATE_TARGET_PRICE),
UPDATED_TARGET_GP: Value(UPDATE_TARGET_GP),
DELETE_REQUESTED: DELETE_REQUEST,
DATE_POSTED: DateTimeValue(Now())

}
)
)

Insight maybe ?

 

Thanks

Dave

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    To start, your formula has the ForAll backward. You are trying to use it like a ForLoop in some development language - which PowerApps is not.  It is a function that returns a table of records based on your iteration table and record schema.

    It is more efficient to use the function as intended and will provide better performance.

     

    So, your formula should be the following:

    Patch(t_redbook_pricing_escalation_detail_Amend,
     ForAll(colFilterAmendDataStart,
     { RBP_MASTER_ID: Value(AUTO_ID),
     PRICING_ESCALATION_ID: Value(RBK_EscalationId_txt.Text),
     SKU: SKU,
     QTY: Value(QTY),
     PRODUCT_DESCRIPTION: PRODUCT_DESCRIPTION,
     TARGET_PRICE: Value(TARGET_PRICE),
     TARGET_GP: Value(TARGET_GP),
     UPDATED_TARGET_PRICE: Value(UPDATE_TARGET_PRICE),
     UPDATED_TARGET_GP: Value(UPDATE_TARGET_GP),
     DELETE_REQUESTED: DELETE_REQUEST,
     DATE_POSTED: Now()
     }
     )
    )

     

    Now, with that done, let's break down some of the other things.

    1) You don't want to do a DateTimeValue on Now()...it already is a DateTimeValue!

    2) If you already have columns in your collection as numeric columns, then you need not do a Value function on them.  The value function is ONLY to convert text to number.

    3) A question: What is the Primary Key of your Table?

    4) A question: Where is RBK_EscalationId_Txt located?  Is that part of a gallery, or just free-standing in your app?

     

    And finally, you appear to already have all the columns listed the same from the collection to the table, so quite honestly, the only thing you really need to do is Patch(t_redbook_pricing_escalation_detail_Amend, colFilterAmendDataStart)

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Randy

    Now, with that done, let's break down some of the other things.

    1) You don't want to do a DateTimeValue on Now()...it already is a DateTimeValue!  =  Thank You!

    2) If you already have columns in your collection as numeric columns, then you need not do a Value function on them.  The value function is ONLY to convert text to number.  = THANK YOU!

    3) A question: What is the Primary Key of your Table?  =  "AUTO_ID" in the sql table...

    4) A question: Where is RBK_EscalationId_Txt located?  Is that part of a gallery, or just free-standing in your app? =

    on another form that carries throughout the app i reference to..

     

    I also, deleted the connection and reestablished the connection and then also things began to work.

    But substituted your patch code with mine...working great now!!

    Thank you

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 224 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard