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 / check value inside a g...
Power Apps
Answered

check value inside a gallery and display message

(0) ShareShare
ReportReport
Posted on by 475

Hello,

 

Hope you're doing good.

 

I have a gallery with numbers that i can edit and save

 

fig1.png

 

 

 

 

 

what i'm trying to do is , when i save (i use a patch function), my numbers should be between 1 and 5,  if one of the fields in the first column equals 0 , it should show a message.

 

I wrote something like this :

 

UpdateContext({varMsg:true});

ForAll(
 RenameColumns(Gallery1.AllItems,"ID","CID"),

 If( Value(ThisRecord.Field1.Text)<1 || Value(ThisRecord.Field1.Text)>5,

 Patch(
 MyList, {ID,CID},{
 "patching my fields"
 },

 UpdateContext({varMsg:false})

 )

);

If(varMsg = true,
 Notify("Success",notificationType.Success),
 Notify("Numbers should be between 1 and 5 - Please check",notificationType.Error)
) 

If i just do the ForAll and the Patch , everything works but when i try to add the 2 conditions ...especially the one inside the ForAll ...it doesn't anymore , it shows errors and just says  the "IF" has invalid parameters.

 

so I tried to change the UpdateContext insde the ForAll and put ({varMsg:false}) only , this doesn;t show an error but it doesn't seem to pick up the value cause whatever i do, it goes to the condition that is outside the ForAll and just shows "success"

 

Would someone have an idea how i can achieve this ?

 

Thanks a lot ! 

 

Categories:
I have the same question (0)
  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Kadd A couple of things,

    • You are missing a close brackets at the end of the Patch
    • You cannot use UpdateContext within a ForAll
    • ({varMsg:false}) wouldn't do anything

    Try this,

    ClearCollect(colMsg,{Msg:true});
    
    ForAll(
     RenameColumns(Gallery1.AllItems,"ID","CID"),
     If( Value(ThisRecord.Field1.Text)<1 || Value(ThisRecord.Field1.Text)>5,
     Collect(colMsg,{Msg:false}),
     Patch(
     MyList, {ID,CID},{
     "patching my fields"
     })
     )
    );
    
    If(false in colMsg.Msg,
     Notify("Numbers should be between 1 and 5 - Please check",notificationType.Error),
     Notify("Success",notificationType.Success)
    );
    
    Clear(colMsg)
  • Kadd Profile Picture
    475 on at

    Hi @CNT ,

     

    Thanks a lot for your answer.

     

    I just readapted the formula as you did but now i have a new error message.

    It take the whole " If " statement and says " Invalid argument type (Record). Expecting a Table value instead"

     

    Again it doesn't really show precisely where the problem is  but "Patch" is underlined more than the rest.

     

    Once again, the patch without the condition works perfectly and inside i just update my text fields 

     

     

    Field1 : Value(GalField1.Text),
    Field2 : Value(GalField2.Text),
    Field3 : Value(GalField3.Text),
    Field4 : {Value:"-"} //this one is a dropdown that i initialise to the "-" value

     

     

    so not sure what's happening here cause nothing seems to be wrong anymore...

     

    thanks

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Kadd I suspect it is the Patch. I would suggest to use a simple Patch with just one field and try if it works.

  • Kadd Profile Picture
    475 on at

    @CNT , i tried it but it doesn't work.

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Kadd Send me a screen shot of the formula with the error message.

  • Verified answer
    Kadd Profile Picture
    475 on at

    @CNT , aaaah i think i got it.

     

    I broke the formula in 2... I first initialize the collection to check and keep the values that are false so i use : 

     

    ClearCollect(colMsg,{Msg:true});
    
    ForAll(
     RenameColumns(Gallery1.AllItems,"ID","CID"),
     If( Value(ThisRecord.Field1.Text)<1 || Value(ThisRecord.Field1.Text)>5,
     Collect(colMsg,{Msg:false})
     )
    );

     

    then i go to the second " If " statement and put the Patch inside when value of the variable is true :

     

    If(false in colMsg.Msg,
     Notify("Numbers should be between 1 and 5 - Please check",notificationType.Error),
     Notify("Success",notificationType.Success);
     ForAll(RenameColumns(Gallery1.AllItems,"ID","CID"),
     Patch(
     MyList, {ID,CID},{
     "patching my fields"
     }))
    );
    
    Clear(colMsg)

     

    cool !!! thanks a lot !!! 🙂

     

     

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Kadd Glad to help!

     

    Please remember to give a 👍 and accept the solution as it will help others in the future.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard