cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Re: Issues running Patch function in PowerApps

Hi Warren, 

 

DOCDETALLE is a Form showing data from a SP list. The list name is SPDOCUMENTOSCP and it stores the head. I am trying to insert the rows using PowerApps, related with that head into another SP list called SPAPLICACIONES. The link between these two lists is the CPID which is a lookup field in SPAPLICACIONES which goes to SPDOCUMENTOSCP and looks up the field CP. For instance, I must have one row in SPDOCUMENTOSCP  with a 5 or N daughter rows in SPAPLICACIONES. These daughter rows must be link to their parent row when I Patch them from PowerApps. 

 

My form is currently working in the following steps: 

1. Clearcollect and it creates 7 fields but it does not include CPID - should I include it? 

2. Then I Patch in the collections the new 7 fields content, again I am not including the CPID because this should not be a text input but instead, every single row in the this Patch should have the same ID of the header in the list SPDOCUMENTOSCP. 

3. Then I Patch the content to Sharepoint. with this query: 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. 

 

 

Highlighted
Community Champion
Community Champion

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?

Highlighted
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper II
Helper II

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. 

Highlighted
Helper II
Helper II

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.

Highlighted
Community Champion
Community Champion

Re: Issues running Patch function in PowerApps

Hi @bolandre92 ,

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

Highlighted
Helper II
Helper II

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

Highlighted
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Community Champion
Community Champion

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

Highlighted
Helper II
Helper II

Re: Issues running Patch function in PowerApps

Hey Kris, 

 

Would it be possible to go for a quick call? 

 

Thank you. 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,743)