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 / iF statement still pro...
Power Apps
Answered

iF statement still processing beyond first condition need it to exit if first condition is true

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Using this code from a dropdown "OnChange" event.

 

I'm still having an issue on the IF statement.

this part:

//action1
If(!IsBlank(LookUp('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]', Status = "Open" && lbl_Racfid_ms.Text = ID_Racfid)),
//condition
     Notify("Check A Row for Open Status !", NotificationType.Warning,4000),

 

I need to exit out of the if statement  if this part is true...

 

It is still proceeding and processing this part ?

//result2
    dwn_ChangeStatus.Selected.Value = "Open",
//condition3
      Patch('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),{Status:"Open"});Set(gblUnsaved, true);
    Set(TheVar,Now());Reset(dwn_ChangeStatus);Set(varCSPSALES, "YES");
    Notify("You Have Opened a Task !", NotificationType.Warning,4000)

 

 

 

 

 

 

 

 

Set(lastActivityTime, Now());
//action1
If(!IsBlank(LookUp('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]', Status = "Open" && lbl_Racfid_ms.Text = ID_Racfid)),
//condition
     Notify("Check A Row for Open Status !", NotificationType.Warning,4000),
//result1
     UpdateContext({varDate: Now()});UpdateContext({varValue: ""});
//result2 
   );
//action2
If(dwn_ChangeStatus.Selected.Value = "In Progress",
//condition1
   Set(varCSPSALES, "NO");Patch(
        '[dbo].[t_nsc_trackcode_trans_time_entry_pa]',
         Defaults('[dbo].[t_nsc_trackcode_trans_time_entry_pa]'),
          {
           NSC_ID_Ref: Value(txt_NextId.Text),
           opened_at: DateTimeValue(txt_ReOpenedDate.Text),
           inprogress_or_closed_at: varDate //Now()
          }
                                   );Patch('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),{Status:"In Progress"});Reset(dwn_ChangeStatus),
//result1
    dwn_ChangeStatus.Selected.Value = "Closed" ,
//condition2
    Set(varCSPSALES, "NO");Patch(
          '[dbo].[t_nsc_trackcode_trans_time_entry_pa]',
           Defaults('[dbo].[t_nsc_trackcode_trans_time_entry_pa]'),
           {
            NSC_ID_Ref: Value(txt_NextId.Text),
            opened_at: If(tbl_Tasks.Selected.Status = "In Progress" ,varDate,tbl_Tasks.Selected.Status = "Open",DateTimeValue(txt_ReOpenedDate.Text)),
            inprogress_or_closed_at: varDate//Now()
            }
    );Patch('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),{
        Status:"Closed",
        Closed_Date:varDate//Now()
        }
    );Notify("Task Has Been Closed !", NotificationType.Warning,4000);Reset(dwn_ChangeStatus),
//result2
    dwn_ChangeStatus.Selected.Value = "Open",
//condition3
      Patch('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),{Status:"Open"});Set(gblUnsaved, true);
    Set(TheVar,Now());Reset(dwn_ChangeStatus);Set(varCSPSALES, "YES");
    Notify("You Have Opened a Task !", NotificationType.Warning,4000)
//result3
);
//action3

 

2 OPEN AT SAME TIME.jpg

Categories:
  • WarrenBelz Profile Picture
    156,750 Most Valuable Professional on at

    Hi @Anonymous ,

    The easiest way would be to use the second condition as a “else” to the first

    Notify("Check A Row for Open Status !",
    NotificationType.Warning,4000),
    If(
     dwn_ChangeStatus.Selected.Value = "Open",
     . . . . .
    )

    You could “nest” the others as well, then the next one will definitely not execute unless,the one above is false.

     

    Please click Accept as solution 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 Thumbs Up.

  • WarrenBelz Profile Picture
    156,750 Most Valuable Professional on at

    Hi @Anonymous ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution 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 Thumbs Up.

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at
    Warren, this is what i ended up doing ,  
    not great, but works..  I did not nest any if's.
     
    dave
     

    // IF THE TASK IS "OPEN" AND PUT "IN PROGRESS"
    If(lbl_Status_Line.Text = "Open" And dwn_ChangeStatus.Selected.Value = "In Progress",
    Patch(
            '[dbo].[t_trackcode_trans_time_entry_pa]',
             Defaults('[dbo].[t_trackcode_trans_time_entry_pa]'),
              {
               NSC_ID_Ref: Value(txt_NextId.Text),
               opened_at: DateTimeValue(txt_ReOpenedDate.Text),
               inprogress_or_closed_at: varDate //Now()
              }
       )
    ;
    Patch('[dbo].[t_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),{Status:"In Progress"}))
    ;
    // IF THE TASK "IN PROGRESS" AND PUT INTO "OPEN" STATUS
    If(lbl_Status_Line.Text = "In Progress" And dwn_ChangeStatus.Selected.Value = "Open", Set(TheVar,Now());Reset(txt_ReOpenedDate)
    ;
    Patch('[dbo].[t_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),{Status:"Open"}))
    ;
    // IF THE TASK IS "IN PROGRESS" AND "CLOSED"
    If(lbl_Status_Line.Text = "In Progress" And dwn_ChangeStatus.Selected.Value = "Closed",
    //MARK THE TIME ENTRY TABLE
    UpdateContext({varDate: Now()})
    ;
    Patch(
            '[dbo].[t_trackcode_trans_time_entry_pa]',
             Defaults('[dbo].[t_trackcode_trans_time_entry_pa]'),
              {
               NSC_ID_Ref: Value(txt_NextId.Text),
               opened_at: varDate,   //DateTimeValue(txt_ReOpenedDate.Text),
               inprogress_or_closed_at: varDate //Now()
              }
       )
     ;
    Patch('[dbo].[t_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),
    {Status:"Closed",
     Closed_Date: varDate
    }))
    ;
    // IF THE TASK IS "OPEN AND PUT "CLOSED"
    If(lbl_Status_Line.Text = "Open" And dwn_ChangeStatus.Selected.Value = "Closed",
    UpdateContext({varDate: Now()})
    ;
    Patch(
            '[dbo].[t_trackcode_trans_time_entry_pa]',
             Defaults('[dbo].[t_trackcode_trans_time_entry_pa]'),
              {
               NSC_ID_Ref: Value(txt_NextId.Text),
               opened_at: DateTimeValue(txt_ReOpenedDate.Text),
               inprogress_or_closed_at: varDate //Now()
              }
       )
    ;
    Patch('[dbo].[t_trackcode_assigned_DataEntry_pa]',LookUp( '[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),
    {Status: "Closed",
     Closed_Date: varDate
    }))
    ;
    // THIS LOOKS FOR AN ENTRY THAT IS PLACED IN "OPEN" STATUS BUT REVERTED BACK BECAUSE THERE IS ALREADY AN "OPEN" STATUS
    If(CountRows(
            Filter('[dbo].[t_trackcode_assigned_DataEntry_pa]',
                Status = "Open",
                ID_Racfid = lbl_Racfid_ms.Text
            )
        )> 1,Set(TheVar,Now());Reset(txt_ReOpenedDate)
    ;
        Patch('[dbo].[t_trackcode_assigned_DataEntry_pa]',
        LookUp('[dbo].[t_trackcode_assigned_DataEntry_pa]',
        NSC_Id = Value(txt_NextId.Text)),{Status:"In Progress"})
       
    )
    ;
    Reset(dwn_ChangeStatus)
     
     
     
     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard