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 / Create records in a ta...
Power Apps
Answered

Create records in a table that combines data from two sources

(0) ShareShare
ReportReport
Posted on by 61
In Power Apps I have a collection called colSelectedCopyTestors and it has a column called ‘1M UAT TestorsID’.

I also have a collection called colSelectedTests and it has columns called UATTestNumber .

I have a table of data called 1M_UAT_Library and it has columns of UATTestNumber, Module, Area, TestName, Resources and 'Requirement Level'.

I also have a table of data called 1M_UAT_ProjectTests and it has a columns called UATTestNumber, Module, Area, Test Name, Resources, ‘1M UAT TestorsID’ and ‘'Requirement Level'.

When a user hits a button, for each combination of records in colSelectedCopyTestors and colSelectedTests I want to add a new record to 1M_UAT_ProjectTests. The following lists the fields in 1M_UAT_ProjectTests and where the value should come from.
UATTestNumber =  colSelectedTests. UATTestNumber
Module = Look up colSelectedTests. UATTestNumber in 1M_UAT_Library. UATTestNumber and return Module
Area = Look up colSelectedTests. UATTestNumber in 1M_UAT_Library. UATTestNumber and return Area
Test Name = Look up colSelectedTests. UATTestNumber in 1M_UAT_Library. UATTestNumber and return TestName
Resources = Look up colSelectedTests. UATTestNumber in 1M_UAT_Library. UATTestNumber and return Resources
‘1M UAT TestorsID’ = colSelectedCopyTestors. ‘1M UAT TestorsID’
'Requirement Level' = Look up colSelectedTests. UATTestNumber in 1M_UAT_Library. UATTestNumber and return 'Requirement Level'
 
I am using this code;
 
ForAll(
    colSelectedCopyTestors,
    ForAll(
        colSelectedTests,
        Patch('1M_UAT_ProjectTests',Defaults('1M_UAT_ProjectTests'),
            {
                UATTestNumber: ThisRecord.UATTestNumber,
                Module: LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).Module,
                Area: LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).Area,
                'Test Name': LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).TestName,
                Resources: LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).Resources,
                'Requirement Level': LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).'Requirement Level',
                '1M UAT TestorsID': ThisRecord.'1M UAT TestorsID'})))
 
But in the line "Patch('1M_UAT_ProjectTests',Defaults('1M_UAT_ProjectTests')," both instances of '1M_UAT_ProjectTests' return an error of "Invalid argument type (Guid). Expecting a Table value instead"
 
Any help on this one would be great. 
Categories:
I have the same question (0)
  • Suggested answer
    SwatiSTW Profile Picture
    807 Super User 2026 Season 1 on at
    The error message you're seeing means that the intended argument types don't match up. In Power Apps, the first argument to the Patch function should be a table or a record, but it's getting a GUID or a value that isn't organized correctly as a table.

    Here's what you can do to fix the problem and your code:

    ForAll(
        colSelectedCopyTestors,
        ForAll(
            colSelectedTests,
            Patch(
                '1M_UAT_ProjectTests',
                Defaults('1M_UAT_ProjectTests'),
                {
                    UATTestNumber: ThisRecord.UATTestNumber,
                    Module: LookUp('1M_UAT_Library', UATTestNumber = ThisRecord.UATTestNumber).Module,
                    Area: LookUp('1M_UAT_Library', UATTestNumber = ThisRecord.UATTestNumber).Area,
                    'Test Name': LookUp('1M_UAT_Library', UATTestNumber = ThisRecord.UATTestNumber).TestName,
                    Resources: LookUp('1M_UAT_Library', UATTestNumber = ThisRecord.UATTestNumber).Resources,
                    'Requirement Level': LookUp('1M_UAT_Library', UATTestNumber = ThisRecord.UATTestNumber).'Requirement Level',
                    '1M UAT TestorsID': ThisRecord.'1M UAT TestorsID'
                }
            )
        )
    )
     
  • AndrianaO Profile Picture
    213 Moderator on at
    Hi! I am not sure if this causes your error, but I would change the following:
     
     
    ThisRecord operator cannot get the value from the outer ForAll() loop, so I would rewrite the formula as follows:
     
    ForAll(
        colSelectedCopyTestors As OuterLoop
    ,
        ForAll(
            colSelectedTests,
            Patch('1M_UAT_ProjectTests',Defaults('1M_UAT_ProjectTests'),
                {
                    UATTestNumber: ThisRecord.UATTestNumber,
                    Module: LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).Module,
                    Area: LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).Area,
                    'Test Name': LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).TestName,
                    Resources: LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).Resources,
                    'Requirement Level': LookUp('1M_UAT_Libraries', UATTestNumber = UATTestNumber).'Requirement Level',
                    '1M UAT TestorsID': OuterLoop.'1M UAT TestorsID'})))
     
     
     
  • Verified answer
    WarrenBelz Profile Picture
    154,411 Most Valuable Professional on at
    The issue is indeed the ambiguity with ThisRecord in a nested ForAll statement. To completely eliminate any ambiguity, try this
    ForAll(
       colSelectedCopyTestors As _Testors,
       ForAll(
          colSelectedTests As _Tests,
          With(
             {
                _Lib:
                LookUp(
                   '1M_UAT_Libraries', 
                   UATTestNumber = _Tests.UATTestNumber
                )
             },
             Patch(
                '1M_UAT_ProjectTests',
                Defaults('1M_UAT_ProjectTests'),
                {
                   UATTestNumber: _Lib.UATTestNumber,
                   Module: _Lib.Module,
                   Area: _Lib.Area,
                   'Test Name': _Lib.TestName,
                   Resources: _Lib.Resources,
                   'Requirement Level': _Lib.'Requirement Level',
                   '1M UAT TestorsID': _Testors.'1M UAT TestorsID'
                }
             )
          )
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee

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!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 103

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
wolenberg_ Profile Picture

wolenberg_ 67 Super User 2026 Season 1

Last 30 days Overall leaderboard