Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Issues running Patch function in PowerApps

(0) ShareShare
ReportReport
Posted on by 73

Hi, 

Any help is greatly appreciate it. 

 

I have create the following patch (I need to insert records from PowerApps to Sharepoint list) and it works perfectly. 

 

Payments = collection

SPAPLICACIONES = Sharepoint list (table B) 

DOCDETALLE = form with input to table A in Sharepoint

 

ForAll(Payments, If(!IsBlank(Comprobante), Patch(SPAPLICACIONES,{COMPROBANTE: Comprobante, MONTO_APLICADO: Monto_Aplicado, MONTO_TOTAL: Monto_Total, MONEDA: Moneda, TIPO: Tipo, PAGO: Pago})))

 

However, when I add just a couple of changes to the patch formula as they are underlying below, it does not run. I have also added the changes individually but it does not run neither.  It worth mentioning that the reason why I am adding the second underlying section is because I am trying to write a link between Table A and Table B, however I have not done any "Last Submit" (any advise here to replace the "Last Submit")

 

ForAll(Payments, If(!IsBlank(Comprobante), Patch(SPAPLICACIONES, Defaults(SPAPLICACIONES), {COMPROBANTE: Comprobante, MONTO_APLICADO: Monto_Aplicado, MONTO_TOTAL: Monto_Total, MONEDA: Moneda, TIPO: Tipo, PAGO: Pago, CPID: DOCDETALLE.LastSubmit.ID})))

 

Thank you in advance

 

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Issues running Patch function in PowerApps

     @bolandre92 ,

    I will leave you will @v-xida-msft here.

    I am sorry my efforts have not reached the result you require.

  • bolandre92 Profile Picture
    bolandre92 73 on at
    Re: Issues running Patch function in PowerApps

    Hey Kris, 

     

    Would it be possible to go for a quick call? 

     

    Thank you. 

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Issues running Patch function in PowerApps

    Hi @bolandre92 ,

    Yes but it will have a name in the data and also a form does not have a Selected property - that can only belong to a control or gallery. 

    Let's get back to basics - can you please send you Patch code that you have included the CPID in - also what is the Item property of the form DOCDETALLE

  • v-xida-msft Profile Picture
    v-xida-msft on at
    Re: Issues running Patch function in PowerApps

    Hi @bolandre92 ï¼Œ

    Based on the formula you provided, I think there is something wrong with it. There is no Selected property supported under the Edit from, so you could not use the DOCDETALLE.Selected.ID formula within your Patch function.

     

    If the Item property of the DOCDETALLE Edit form is set to a LookUp formula, you could apply same LookUp formula logic within your Patch function as well, and then you could reference the ID column value under the LookUp formula result:

    ForAll(
     Payments, 
     If(
     !IsBlank(Comprobante), 
     Patch(
     SPAPLICACIONES,
     Defaults(SPAPLICACIONES),
     {
     COMPROBANTE: Comprobante, 
     MONTO_APLICADO: Monto_Aplicado, 
     MONTO_TOTAL: Monto_Total, 
     MONEDA: Moneda, 
     TIPO: Tipo, 
     PAGO: Pago, 
     CPID: LookUp(SPDOCUMENTOSCP, PrimaryColumn = "Specific Value xxxx").ID // Please understand the LookUp formula here
     }
     )
     )
    )

    Note: The LookUp(SPDOCUMENTOSCP, PrimaryColumn = "Specific Value xxxx") formula represents the LookUp formula you typed within the Item property of the DOCDETALLE Edit from.

     

    If the Item property of the DOCDETALLE Edit from is bind to Gallery Selected Item, please assign the following formula to the CPID filed in above Patch formula:

    Gallery1.Selected.ID

     

    If you still could not understand this solution, I think maybe a quick call could help your scenario better.

     

    Best regards,

  • bolandre92 Profile Picture
    bolandre92 73 on at
    Re: Issues running Patch function in PowerApps

    Hi Warren, 

     

    This is how the Patch looks like: 

     

    ForAll(Payments, If(!IsBlank(Comprobante), Patch(SPAPLICACIONES,{COMPROBANTE: Comprobante, MONTO_APLICADO: Monto_Aplicado, MONTO_TOTAL: Monto_Total, MONEDA: Moneda, TIPO: Tipo, PAGO: Pago, CPID: DOCDETALLE.Selected.ID})))

     

    I also got these two error in case they give us a hint: 

     

    1. The type of this argument 'CPID' does not match the expected type 'Record'. Found type 'error'

    2. The function Patch has some invalid arguments

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Issues running Patch function in PowerApps

    Hi @bolandre92 ,

    Yes you are close - what did you call the CPID in the Patch?

  • bolandre92 Profile Picture
    bolandre92 73 on at
    Re: Issues running Patch function in PowerApps

    These videos are very useful, I have already used them for this project, however, I still stuck. =(

     

    Thks.

  • bolandre92 Profile Picture
    bolandre92 73 on at
    Re: Issues running Patch function in PowerApps

    Hi, 

     

    Yes I have tried, I think I am very close. 

     

    I have inserted the CPID clomun as CPID: 0 in the collections as @WarrenBelz mentioned, therefore, I have also included the CPID section in the Patch as you mentioned in your earlier message but I still have an error in the formula which is underlying below:

     

    ForAll(Payments, If(!IsBlank(Comprobante), Patch(SPAPLICACIONES,{COMPROBANTE: Comprobante, MONTO_APLICADO: Monto_Aplicado, MONTO_TOTAL: Monto_Total, MONEDA: Moneda, TIPO: Tipo, PAGO: Pago, CPID: DOCDETALLE.Selected.ID})))

     

    Thank you. 

  • v-xida-msft Profile Picture
    v-xida-msft on at
    Re: Issues running Patch function in PowerApps

    Hi @bolandre92 ,

    Have you taken a try with the solution I provided above? Is it helpful in your scenario?

     

    Please consider take a try with the above solution I provided, then check if the issue is solved. Based on the needs that you mentioned, I think the following video would help in your scenario:

    https://www.youtube.com/watch?v=xgznk4XlPCo&t=839s

    https://www.youtube.com/watch?v=DylxsXIUyDc&t=17s

    https://www.youtube.com/watch?v=HUX_0AA4-Hs&t=1s

     

    Best regards,

  • WarrenBelz Profile Picture
    WarrenBelz 145,422 on at
    Re: Issues running Patch function in PowerApps

    Hi @bolandre92 

    Answer to question 1 is definitely Yes

    When you say it should not be a text input, this can be easily converted to a number with the Value() function. So if you had the CPID as text in a collection field called CPIDNo, you would simply Patch Value(CPIDNo) - is this what you are meaning? If so you do not need the LastSubmit() reference. If it is always the same number, I assume including it in the Collection will do the same.

    Am I correct in the assumptions above?

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard