Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

can i set() on forall() or not ?

(1) ShareShare
ReportReport
Posted on by 2
hi i'm beginner for powerapp  trying to check condition in toggle input  by forall () in collection that keep toggle input like 
 
UpdateContext({check_result: true});
 
ClearCollect(
    ck_val,[
        {dt: tg_open.Checked},
        {dt: tg_close.Checked},
        {dt: tg_dis.Checked},
        {dt: tg_bt.Checked},
        {dt: tg_fn.Checked},
        {dt: tg_tp.Checked}
    ]
);
 
ForAll(
    ck_val,
    If(
        ThisRecord.dt = false,
        UpdateContext({check_result: false}) // it call cannot invoke on this function 
    )
);

 
Categories:
  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    can i set() on forall() or not ?
    Just following up to see if you received the answer you needed, or if you require further assistance.

    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
  • WarrenBelz Profile Picture
    WarrenBelz 145,445 on at
    can i set() on forall() or not ?
    Firstly, what @SudeepGhatakNZ has posted will work fine - another shorter version would be to set check_result directly so it will be true if all are checked, otherwise false.
    UpdateContext(
       {
          check_result: 
          tg_open.Checked && tg_close.Checked && tg_dis.Checked && tg_bt.Checked && tg_fn.Checked && tg_tp.Checked
       }
    ) 
     
  • Suggested answer
    SudeepGhatakNZ Profile Picture
    SudeepGhatakNZ 14,231 on at
    can i set() on forall() or not ?
    The ForAll() function is not designed to return results directly in the same way a loop would in a traditional programming language. 
    Specifically, it doesn't allow you to modify the context or variables inside it in the way you're trying to do with. Try the following:
    
    // Initialize the context variable to true first
    UpdateContext({check_result: true});
    
    // Collect all the toggle values into a collection
    ClearCollect(
        ck_val, 
        [
            {dt: tg_open.Checked},
            {dt: tg_close.Checked},
            {dt: tg_dis.Checked},
            {dt: tg_bt.Checked},
            {dt: tg_fn.Checked},
            {dt: tg_tp.Checked}
        ]
    );
    
    // Check if any of the values in the collection are false
    If(
        !IsBlank(LookUp(ck_val, dt = false)),
        UpdateContext({check_result: false})
    )
    

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard