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 / Set Variables after a ...
Power Apps
Unanswered

Set Variables after a ForAll

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone,

 

I am having trouble with reading a NFC and then setting some variables. I have a ForAll as shown in the code that makes the

Patch only possible if it's the right NFC tag. The problem here is that I want to show a popup when the tag has been scanned but it doesn't allow me to do so in the ForAll function.

 

With(ReadNFC(),
 Set(id, Coalesce(Identifier, "No ID"));
 ForAll(NDEFRecords, 
 If(Coalesce(Text, URI) = "SWELL",
 ForAll(NDEFRecords, Patch('Controlo de Ponto', Defaults('Controlo de Ponto'), {'Entrada/Saída': "ENTRADA", Title: User().FullName, Email: User().Email, 'Dia e Hora': Now()})); 
)));
Set(varDisableButton, false);
Set(PP3, false);
Set(PP1, true);
Set(T1, true);

 

Do you have any suggestions for me so I can fix this? Thank you in advance!

Categories:
I have the same question (0)
  • Shaheer Ahmad Profile Picture
    2,194 Moderator on at

    Hey Rui_Couto,

    Looks like you're wrestling with the ForAll function and trying to set variables after scanning an NFC tag. Handling stuff inside ForAll can be a bit tricky. Here's a tweak to your code to get that popup showing:

    With(
     ReadNFC(),
     Set(id, Coalesce(Identifier, "No ID"));
     If(
     !IsBlank(
     Filter(
     NDEFRecords,
     Coalesce(Text, URI) = "SWELL"
     )
     ),
     Patch(
     'Controlo de Ponto',
     Defaults('Controlo de Ponto'),
     {
     'Entrada/Saída': "ENTRADA",
     Title: User().FullName,
     Email: User().Email,
     'Dia e Hora': Now()
     }
     )
     )
    );
    Set(varDisableButton, false);
    Set(PP3, false);
    Set(PP1, true);
    Set(T1, true);

    I added a condition around the Patch inside the ForAll loop to check if there's a match for "SWELL" in the NDEFRecords before doing the patch. This way, it won't mess up your flow.

    Give it a whirl, and let me know if the popup decides to make an appearance! 🌟

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Unfortunately this didn't work... I used a NFC tag without SWELL text on it and it worked... I want to read that specific tag. But thanks anyways!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 413

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
timl Profile Picture

timl 315 Super User 2026 Season 1

Last 30 days Overall leaderboard