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 / Collect and Patch issue
Power Apps
Unanswered

Collect and Patch issue

(0) ShareShare
ReportReport
Posted on by

Hello great community!

I'm in need of help.

I've an powerApps where the user scans physical QR-Codes with Barcode Scanner control.
I can't seem to collect nor patch one of the values i need called 'ENHET'. When i set the 'Enhet': lclUnit, it returns an error message saying it's an incompatible type, when i put the Text() function before, it returns the same error message.

Basically When the user scans a QR-Code, the variable gvarQR looks in my 'North Lager Saldo' SP List to find the Unit Value of that row and then displays it in the Label.

However i can't seem to figure out how to collect it, i want it to patch that value into my 'uttag av Material' SP List
I'm sorry if the explanation is bad

I've attached 3 images.

1. Collect Button Formula
2. Text Property of my 'Enhet' label
3. Patch Button Formula


Best Regards

Collect Formula.PNG
Patch Formula.PNG
Text Property Enhet.PNG
Categories:
  • EddieE Profile Picture
    4,650 Moderator on at

    @VincentGiovanni 

    Have you tried removing the .Value from your LookUp function? I'm not sure why you are using that code structure because you are already referencing the column name called 'Unit' inside your LookUp.

     

    If you post your code into a code window I can try to rewrite it for you.

  • VincentGiovanni Profile Picture
    on at

    Hello EddieE, 

    Are u referring to my Text Property formula?

    Text(
     LookUp(
     'Norra Lager Saldo';
     StringQRKod = gvarQR;
     Unit
     ).Value
    )


    Or my collect button?

    // Data Validation for 'gvarQR'
    If(
     IsBlank(gvarQR);
     Notify(
     MicrosoftTranslator.Translate(
     "Du måste skanna produktens QR-kod för att fortsätta";
     rdoLang.Selected.Value
     );
     NotificationType.Error
     );
     // If all validations pass, proceed with the collect operation
    // If either 'gvarID06' or 'noIdNameTxtInp.Text' is not blank, proceed with the collect operation
     If(
     IsBlank(ID06Scanner.Value) && !IsBlank(noIdNameTxtInp.Text);
     Set(
     gvarID06;
     noIdNameTxtInp.Text
     );
     Set(
     gvarID06;
     ID06Scanner.Value
     )
     );;
     // Local Variable for Article number
    UpdateContext({lclArt: SkannaQrArtValLbl.Text});;
     UpdateContext(
     {
     lclUnit: LookUp(
     'Norra Lager Saldo';
     Artikelnummer = gvarQR;
     Unit
     )
     }
     );;
     // Data Validation for numeric Input and collect values from different inputs
    If(
     IsNumeric(SkannaQrAntalTxtInp.Text) && Text(Value(SkannaQrAntalTxtInp.Text) >= 1);
     Collect(
     colUttag;
     {
     IDKort: gvarID06;
     Artikelnummer: lclArt;
     Produkt: gvarQR;
     Antal: Text(Value(SkannaQrAntalTxtInp.Text));
     Tidspunkt: Now();
     Enhet: LookUp(
     'Norra Lager Saldo';
     Artikelnummer = lclArt;
     Unit
     )
     }
     );
     Notify(
     MicrosoftTranslator.Translate(
     "Du får bara skriva siffror för mängd, inga bokstäver och decimaler";
     rdoLang.Selected.Value
     );
     NotificationType.Error
     )
     )
    );;
    Reset(SkannaQrAntalTxtInp);;
    Set(
     gvarQR;
     Blank()
    )

     

    Patch button formula

    Navigate(KlarScreen);;
    Notify(
     MicrosoftTranslator.Translate(
     "Uttag registrerat och klart! Tack så mycket";
     rdoLang.Selected.Value
     );
     NotificationType.Success
    );;
    // For each item in the collection "colUttag", which is defined as "Varukorg", update the record in the "Norra Lager Saldo" data source
    ForAll(
     colUttag As Varukorg;
     Patch(
     'Norra Lager Saldo';// target data source
     LookUp(
     'Norra Lager Saldo';// data source to look up in
     Artikelnummer = Varukorg.Artikelnummer// condition for the lookup
     );
     {
     Antal: LookUp(// update the "Antal" field
     'Norra Lager Saldo';// data source to look up in
     Artikelnummer = Varukorg.Artikelnummer// condition for the lookup
     ).Antal - colAntVal// value to update the "Antal" field with, which is the result of the subtraction of "Antal Label" from the current "Antal" value
     }
     )
    );;
    // For each item in the "colUttag" collection, create a new record in the "Uttag av material" data source
    ForAll(
     colUttag;
     Patch(
     'Uttag av material';// target data source
     Defaults('Uttag av material');// create a new record with default values
     {
     idKort: IDKort;
     // update the "idKort" field
     ArtikelNummer: Artikelnummer;
     // update the "ArtikelNummer" field
     Produkt: Produkt;
     // update the "Produkt" field
     Kvantitet: Antal;
     // update the "Antal" field
     Tidspunkt: Tidspunkt;
     // update the "Tidspunkt" field
     Site: {Value: "Norra"}
     }
     )
    );;
    // Clear the "colUttag" collection
    Clear(colUttag);;
    Set(
     gvarID06;
     Blank()
    );;
    Reset(noIdNameTxtInp);;
    Navigate(KlarScreen)

     

  • VincentGiovanni Profile Picture
    on at
  • EddieE Profile Picture
    4,650 Moderator on at

    @VincentGiovanni 

    This code structure looks correct

    UpdateContext(
     {
     lclUnit: LookUp(
     'Norra Lager Saldo';
     Artikelnummer = gvarQR;
     Unit
     )
     }
     );;

    whereas this code structure doesn't

    Text(
     LookUp(
     'Norra Lager Saldo';
     StringQRKod = gvarQR;
     Unit
     ).Value
    )

     

    The second one is using the .Value and doesn't look right, but this may depend on the datasource - not sure?

  • VincentGiovanni Profile Picture
    on at

    @EddieE 

    The Datasource is a SP List where the 'Unit' column is a LookUp Column.

    Norra Lager Saldo Items.PNG
    Norra Lager Saldo SP list.PNG
  • EddieE Profile Picture
    4,650 Moderator on at

    @VincentGiovanni 

    The lclUnit variable is returning a Table whereas the Text property is returning a Text string, hence the incompatible type error - you cannot compare and/or use two different types inside of your code. You need to decide which way you need to go and just use one of them.

     

    I don't use LookUp Columns inside my PowerApps, I just avoid them because they cause too many issues. They are good for using inside of SharePoint - if that's what your users need to do - but if they don't I'd recommend to have the PowerApp do the LookUp to the second list, if possible?

  • VincentGiovanni Profile Picture
    on at

    @EddieE 

    I see, I use the LookUp function to retrieve the Unit Data from my north SP List based on gvarQR result to find matching result, and the purpose was to somehow convert the retrieved value to string/Text fromat for it to patch to my 'Uttag av Material' (scanned articels) SP List (which is a text column).

    Unfortunately, i'm no professional what so ever in PowerApps. Do you suggest a solution or perhaps Flow is a better way to go? 

    'Uttag av Material' SP List.PNG
    Uttag av Material SP List Columns.PNG
  • VincentGiovanni Profile Picture
    on at

    It seems that the solution should be simple but i can't seem to figure it out...

  • EddieE Profile Picture
    4,650 Moderator on at

    @VincentGiovanni 

    The only thing I can see that maybe wrong is how the variable gvarQR is created. I am able to display a value in a label for a LookUp column I have in a Test List using code that matches yours, eg

    LookUp( myList, CampName = "Test Camp", CampLookUp).Value

    CampLookUp is the name of the lookup column and this works fine.

     

    It's possible you are referencing something else ... somewhere ... but I cannot see where, sorry

     

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 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard