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 Function in Canv...
Power Apps
Unanswered

Patch Function in Canvas app to update 2 tables

(0) ShareShare
ReportReport
Posted on by 92

Hi,

 

i am writing a barcode reader app, which is basically scanning barcodes and then checking the dataverse table: contact for eg.

 

If the barcode is found in the table, then update a field, set it to true.

 

Else, if not found, create a new record with the value of that barcode in another table (which has 1 column: number).

 

Here is the code that i have created on the barcode reader component:

Set(
    varScan,
    First(Self.Barcodes).Value
);
Set(
    varRecord,
    LookUp(
        'Asset Managements',
        'Asset Number' = varScan
    )
);
//checks if the asset number is equal to the variable scanned
/*If(
    IsBlank(varRecord),
    Set(
        varRecord,
        Defaults('Asset Managements')
    )
);
*/
If(
    IsBlank(varRecord.'Asset Number'),
    /*Set(
        varRecord,
        Patch(
            'Asset Managements',
            varRecord,
            {'Marche validée': false}
        )
       
    );
    */

    /*
    IsError(
    Patch(
        'Marcheur Non Reconnus',
        Defaults('Marcheur Non Reconnus'),
        {'Asset Number': varScan}
    );), Notify("Error has occured",NotificationType.Error), Notify("Successful",NotificationType.Success)
    */
    Patch('Not Recogniseds', Defaults('Not Recogniseds'), {number:varScan})
    ,
    Set(
        varRecord,
        Patch(
            'Asset Managements',
            varRecord,
            {'Marche validée': true}
        )
    );
   
);

/*
If(
    IsBlank(varRecord),
    Patch(
        'Marcheur Non Reconnus',
        Defaults('Marcheur Non Reconnus'),
        {'Asset Number': varScan}
    )
);
*/
Navigate(ButtonScreen);
 
 
my issue is that it is not creating the new record in the 'not recognised' table.
 
Please help.
 
Thank you

 

 

Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @AsheshR 

     

    can you try this please:

    // Capture the scanned barcode value.
    Set(varScan, First(Self.Barcodes).Value);
    
    // Attempt to find the scanned barcode in the 'Asset Managements' table.
    Set(varRecord, LookUp('Asset Managements', 'Asset Number' = varScan));
    
    // Determine whether the barcode was found.
    If(
     IsBlank(varRecord),
     // If the barcode is not found, try to create a new record in the 'Not Recogniseds' table.
     If(
     IsError(
     Patch('Not Recogniseds', Defaults('Not Recogniseds'), {number: varScan})
     ),
     Notify("Error occurred while creating a new record.", NotificationType.Error), // Notify if an error occurs
     Notify("A new record was successfully created.", NotificationType.Success) // Notify if successful
     ),
     // If the barcode is found, update the 'Marche validée' field to true.
     Set(
     varRecord,
     If(
     IsError(
     Patch('Asset Managements', varRecord, {'Marche validée': true})
     ),
     Notify("Error occurred while updating the record.", NotificationType.Error), // Notify if an error occurs
     Notify("Record was successfully updated.", NotificationType.Success) // Notify if successful
     )
     )
    );
    
    // Navigate to another screen after operation.
    Navigate(ButtonScreen);
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • AsheshR Profile Picture
    92 on at

    Hey,

     

    very grateful for helping me. getting some lines in red code, as follows:

    AsheshR_0-1712147737331.png

     

    and here also:

    AsheshR_1-1712147774662.png

     

     

  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    can you also let us know which error message you see?

  • AsheshR Profile Picture
    92 on at

    before applying your new code, i have done : Clone solution.

     

    is it a mistake that i have done?? 😞

  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    what do you mean by clone solution?

     

  • AsheshR Profile Picture
    92 on at

    AsheshR_0-1712148144286.png

     

     

    AsheshR_1-1712148157751.png

     

  • AsheshR Profile Picture
    92 on at

    in the Solution Explorer, i clicked on the 3 dots and then selected Clone > Clone Solution.

     

    i wanted to make a backup copy before putting your new code ..

  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    should not really make a difference in my opinion

     

     

  • AsheshR Profile Picture
    92 on at

    Thank you. did you have a look at the errors underlined in red? its telling the function IsBlank has some invalid argument type..

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard