Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

ForAll issue

(0) ShareShare
ReportReport
Posted on by 152
ForAll(CollLang,
    If(IsBlank(ThisRecord.ID),
    Patch('Languages spoken',Defaults('Languages spoken'),{Language:ThisRecord.Language,'Language Proficiency':ThisRecord.'Language Proficiency','Social Insurance Number':varsocial}),
    Patch('Languages spoken',{Language:ThisRecord.Language,'Language Proficiency':ThisRecord.'Language Proficiency','Social Insurance Number':varsocial})))
 
 
I have above formula that takes  the collection i made from a condition .The logic is to update already existing records if they are old and create new records if they are new.For some reason it always creates new records.I can see in my collection that new records indeed have a blank ID but still a new record is created
 
Can someone assist please? 
  • Verified answer
    mmbr1606 Profile Picture
    13,050 Super User 2025 Season 1 on at
    ForAll issue
    hey
     
    thanks for the update:
     
    ForAll(
        CollLang As Lang,
        If(
            IsBlank(Lang.ID),
            // Create new
            Patch(
                'Languages spoken',
                Defaults('Languages spoken'),
                {
                    Language: Lang.Language,
                    'Language Proficiency': Lang.'Language Proficiency',
                    'Social Insurance Number': varsocial
                }
            ),
            // Update existing
            Patch(
                'Languages spoken',
                LookUp('Languages spoken', ID = Lang.ID),
                {
                    Language: Lang.Language,
                    'Language Proficiency': Lang.'Language Proficiency',
                    'Social Insurance Number': varsocial
                }
            )
        )
    )
    
    If your "Language spoken" tables ID column is a GUID rather than a number, ensure to use GUID( ) in the lookup filter or cast the types appropriately.
     
     

    If my answer was helpful and solved your issue, please mark it as the verified answer.

    If it helped but didn’t fully solve it, I’d appreciate a like. 😊

    And if you’d like to support me, feel free to buy me a coffee.

  • NM-06090901-0 Profile Picture
    152 on at
    ForAll issue
     
    Adding the lookup gave me a 400 error 
     
    Error when trying to retrieve data from the network: Fetching items failed. Possible invalid string in filter query
     
    After using the below i got it resolved with the (As)
     
     
    ForAll(
        CollLang As Lang,
        If(
            IsBlank(Lang.ID),
            // Create new
            Patch(
                'Languages spoken',
                Defaults('Languages spoken'),
                {
                    Language: Lang.Language,
                    'Language Proficiency': Lang.'Language Proficiency',
                    'Social Insurance Number': varsocial
                }
            ),
            // Update existing
            Patch(
                'Languages spoken',
                LookUp('Languages spoken', ID = Lang.ID),
                {
                    Language: Lang.Language,
                    'Language Proficiency': Lang.'Language Proficiency',
                    'Social Insurance Number': varsocial
                }
            )
        )
    )
     
  • mmbr1606 Profile Picture
    13,050 Super User 2025 Season 1 on at
    ForAll issue
    hey
     
     
    can u try this:
    ForAll(
        CollLang,
        If(
            IsBlank(ThisRecord.ID),
            // Create new
            Patch(
                'Languages spoken',
                Defaults('Languages spoken'),
                {
                    Language: ThisRecord.Language,
                    'Language Proficiency': ThisRecord.'Language Proficiency',
                    'Social Insurance Number': varsocial
                }
            ),
            // Update existing
            Patch(
                'Languages spoken',
                LookUp('Languages spoken', ID = ThisRecord.ID),
                {
                    Language: ThisRecord.Language,
                    'Language Proficiency': ThisRecord.'Language Proficiency',
                    'Social Insurance Number': varsocial
                }
            )
        )
    )
    
     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1