web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Only Part of Button On...
Power Apps
Unanswered

Only Part of Button OnSelect Executed (First action in if statement only)

(1) ShareShare
ReportReport
Posted on by 71
I have a form with two columns of Toggles, before and after. Before pulls from a list, after is set by the user. Several of these are local area lists, and then there is a list that holds archived items. When I run this code on the OnSelect of my button, the RemoveIf executes for List A but not B-G. The rest of the code also executes fine, and I'm baffled. I'm hoping I'm overlooking something silly.
 
 If(Transaction_Type="Type 4",
 
            If('A Before DataCardValue'.Checked=true,
                RemoveIf('A - Activity Catalog',Title=Target_Editing));
            If('B Before DataCardValue_1'.Checked=true,
               RemoveIf('B - Activity Catalog',Title=Target_Editing));
            If('C_Before DataCardValue'.Checked=true,
                RemoveIf('C - Activity Catalog',Title=Target_Editing));
            If('D Before DataCardValue'.Checked=true,
                RemoveIf('D - Activity catalog',Title=Target_Editing));
            If('E Before DataCardValue'.Checked=true,
                RemoveIf('E - Activity Catalog',Title=Target_Editing));
            If(F_Before_DataCardValue.Checked=true,
                RemoveIf('F - Activity catalog',Title=Target_Editing));
            If(G_Before_DataCardValue.Checked=true,
                RemoveIf('G - Activity catalog',Title=Target_Editing));
               
    ForAll(Origin_ItemsPatch('Archived  -  Activity catalog',{'Target Name':Target_Editing,'Activity Title':field_1,Status:ThisRecord.field_2,'specific restrictions':ThisRecord.field_3,'Example behavioral Goal':ThisRecord.field_4}));
 
        Patch('Master Inventory for activities',LookUp('Master Inventory for activities',Title=Target_Editing),{'Archived?':{Value:("Yes")}, A:false,B:false,C:false,D:false,E:false,F:false,G:false});Notify("Target Has Been Archived from All Areas",NotificationType.Success,3000));
Categories:
I have the same question (0)
  • BhargavPatel Profile Picture
    660 Moderator on at
    Have you included the entire PowerFx? I don't see the end of the first If statement. 
  • Suggested answer
    Ravi-Prajapati Profile Picture
    416 Super User 2025 Season 2 on at
    Close the 'If' statement in case you do not need else part
  • WarrenBelz Profile Picture
    153,049 Most Valuable Professional on at
    I have parsed your code below for ease of reference and made a suggestion in the first Patch statement for better performance. I also noticed you have imported the list initially from Excel (the field_x names), which may cause you some unwanted confusion later on, but neither of these are your current issue.
     
    There is nothing fundamentally wrong with your code structure and it should execute sequentially (the If statements are separate tests all the way down), which may only leave one thing - the Modern checkboxes. Can you please test with Classic Check Boxes (you will need .Value rather than .Checked ) and see if that works. I am assuming here that Target_Editing is a string Variable.
    If(
       Transaction_Type="Type 4",
       If(
          'A Before DataCardValue'.Checked,
          RemoveIf(
             'A - Activity Catalog',
             Title = Target_Editing
          )
       );
       If(
          'B Before DataCardValue_1'.Checked,
          RemoveIf(
             'B - Activity Catalog',
             Title = Target_Editing
          )
       );
       If(
          'C_Before DataCardValue'.Checked,
          RemoveIf(
             'C - Activity Catalog',
             Title = Target_Editing
          )
       );
       If(
          'D Before DataCardValue'.Checked,
          RemoveIf(
             'D - Activity catalog',
             Title = Target_Editing
          )
       );
       If(
          'E Before DataCardValue'.Checked,
          RemoveIf(
             'E - Activity Catalog',
             Title = Target_Editing
          )
       );
       If(
          F_Before_DataCardValue.Checked,
          RemoveIf(
             'F - Activity catalog',
             Title = Target_Editing
          )
       );
       If(
          G_Before_DataCardValue.Checked,
          RemoveIf(
             'G - Activity catalog',
             Title = Target_Editing
          )
       );
       Patch(
          'Archived  -  Activity catalog',
          ForAll(
             Origin_Items As _Data, 
             {
                'Target Name': Target_Editing,
                'Activity Title': _Data.field_1,
                Status: _Data.field_2,
                'specific restrictions': _Data.field_3,
                'Example behavioral Goal': _Data.field_4
             }
          )
       );
       Patch(
          'Master Inventory for activities',
          LookUp(
             'Master Inventory for activities',
             Title = Target_Editing
          ),
          {
             'Archived?': {Value:("Yes")}, 
             A: false,
             B: false,
             C: false,
             D: false,
             E: false,
             F: false,
             G: false
          }
       );
       Notify(
          "Target Has Been Archived from All Areas",
          NotificationType.Success,
          3000
       )
    );
     
    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    LinkedIn   
  • CU12092006-0 Profile Picture
    71 on at
    @WarrenBelz Thank you for that. A large chunk of my app is based on a 7 row pseudo table of before and after inputs, so this would require a lot of recoding I think. Also these are toggles rather than true checkboxes, if that changes anything. Would an intermediate variable being used in the if statement work instead? 
     
    For example: 
     
     
    OnCheck, OnSelect, and On UnCheck of each of the toggles: Set (ABefore, Self.Checked) and Set (AAfter, Self.Checked) respectively for the before column and after columns.
     
    Then: 
    If(
       Transaction_Type="Type 4",
       If(
          'ABefore = Checked,
          RemoveIf(
             'A - Activity Catalog',
             Title = Target_Editing
          )
       );
       If(
          'BBefore = Checked,
          RemoveIf(
             'B - Activity Catalog',
             Title = Target_Editing
          )
       );
       
     
    and so on and so forth. 
     
    I'll take a look at the patch suggestion as well.
     
    Edit: I tried this with intermediate variables and it still only executes the first RemoveIf indicated. But the variable appear to be updating as expected.
     
    Edit2: I tried this after substituting areas A, B, and C both before and after with classic checkboxes, and it now adds the items to the archived list but does not remove from lists A, B, or C.
  • WarrenBelz Profile Picture
    153,049 Most Valuable Professional on at
    Depending on where those toggles are, they may be getting reset, so try this - I am assuming a Classic Toggle, so have used .Value
    With(
       {
          _A: 'A Before DataCardValue'.Value,
          _B: 'B Before DataCardValue'.Value,
          _C: 'C Before DataCardValue'.Value,
          _D: 'D Before DataCardValue'.Value,
          _E: 'E Before DataCardValue'.Value,
          _F: 'F Before DataCardValue'.Value,
          _G: 'G Before DataCardValue'.Value
       },
       If(
          Transaction_Type  ="Type 4",
          If(
             _A,
             RemoveIf(
                'A - Activity Catalog',
                Title = Target_Editing
             )
          );
          If(
             _B,
             RemoveIf(
                'B - Activity Catalog',
                Title = Target_Editing
             )
          );
          If(
             _C
             RemoveIf(
                'C - Activity Catalog',
                Title = Target_Editing
             )
          );
          If(
             _D,
             RemoveIf(
                'D - Activity catalog',
                Title = Target_Editing
             )
          );
          If(
             _E,
             RemoveIf(
                'E - Activity Catalog',
                Title = Target_Editing
             )
          );
          If(
             _F,
             RemoveIf(
                'F - Activity catalog',
                Title = Target_Editing
             )
          );
          If(
             _G,
             RemoveIf(
                'G - Activity catalog',
                Title = Target_Editing
             )
          )
       )
    )
    
     
    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    LinkedIn   
  • CU12092006-0 Profile Picture
    71 on at
    @WarrenBelz I tried that code and it is still only executing removal from the first list. I do have resets built into the app to facilitate multiple transactions and changes midway. That said:
     
    I parsed all of my transaction types into independent buttons to make it easier to read and remove the levels of nested IFs (Button visibility toggled by transaction type instead).
     
    I would have thought that everything would execute sequentially,  but just to test, I removed the part of the archival button onselect that reset master inventory (which also resets the toggles) and utilized your With technique. Unfortunately, that still only executes the operation from the first list. 
     
    I can unarchive from the archives to the multiple lists just fine, but when I try to archive from multiple lists to the archives, only removal from the first list executes. I still can't figure out why. The reset issue makes sense but I can't locate where it is happening. I'm not even referencing those intermediary variables, plus they are set to reset on change of each the toggle.Checked which I removed for the purposes of testing. 
  • WarrenBelz Profile Picture
    153,049 Most Valuable Professional on at
    Have you run a monitor session to see what it is doing ? Also what is your data source (I should have asked this earlier). How many records are in your lists and do you have this turned on
  • WarrenBelz Profile Picture
    153,049 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for or if you need 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    LinkedIn   

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard