cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Partisan
Post Partisan

check value in label then make perform code

I have a dropdown with onChange event happening below.

I have a label with a numeric value in it.  "lbl_Open_Chk"

if that value  =  1 in the label I do not want the code below to execute.

I need a warning stating a "task is already open"

 

If(dwn_ChangeStatus.Selected.Value = "Open",Set(TheVar,Now());
Reset(txt_ReOpenedDate));
If(dwn_ChangeStatus.Selected.Value = "Open",Set(varCSPSALES, "YES"));
If(dwn_ChangeStatus.Selected.Value = "Closed",Set(varCSPSALES, "YES"));
If(dwn_ChangeStatus.Selected.Value = "In Progress",Set(varCSPSALES, "NO"));

Thanks

Dave 

7 REPLIES 7
Highlighted
Resolver III
Resolver III

Re: check value in label then make perform code

Hi @DAVIDPOWELL, I would try something like below. Add the code to OnChange event of dropdown control. First, I am checking to see if level value is "1" to display warning and in else condition adding a Switch control which is better performing as compare to multiple if statements.

 

If(
    lbl_Open_Chk.Text = "1",
    Set(
        varCSPSALES,
        "Task is already open"
    ),
    Switch(
        dwn_ChangeStatus.SelectedText.Value,
        "Open",
        Set(
            varCSPSALES,
            "YES"
        );
        Set(
            TheVar,
            Now()
        ),
        "Closed",
        Set(
            varCSPSALES,
            "YES"
        ),
        "In Progress",
        Set(
            varCSPSALES,
            "NO"
        )
    )
)

 

Thanks

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.

Thanks

Highlighted
Super User
Super User

Re: check value in label then make perform code

Hi,

 

You should be able to do the following logic:

If the textbox content is equal to 1, show a notification, otherwise execute the code you had previously

 

This would look like:

 

If(
   lbl_Open_Chk.Text = "1",
   Notify("Task is already open", NotificationType.Warning),

   //Otherwise if not equal to 1 then perform existing code
   If(dwn_ChangeStatus.Selected.Value = "Open",Set(TheVar,Now());
   Reset(txt_ReOpenedDate));
   If(dwn_ChangeStatus.Selected.Value = "Open",Set(varCSPSALES, "YES"));
   If(dwn_ChangeStatus.Selected.Value = "Closed",Set(varCSPSALES, "YES"));
   If(dwn_ChangeStatus.Selected.Value = "In Progress",Set(varCSPSALES, "NO"));
)

 

 

Cheers,

Sancho


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Highlighted
Resolver III
Resolver III

Re: check value in label then make perform code

@DAVIDPOWELL - sorry, I miss read your notification question which @iAm_ManCat (Sancho) covered in his response. So, here is the updated code:

If(
    lbl_Open_Chk.Text = "1",
    Notify("Task is already open", NotificationType.Warning),
    //If label value is not equal to "1"
    Switch(dwn_ChangeStatus.SelectedText.Value,
        "Open",
          Set(varCSPSALES, "YES");
          Set(TheVar, Now()),
        "Closed",
          Set(varCSPSALES, "YES"),
        "In Progress",
          Set(varCSPSALES, "NO")
    )
)

 

Highlighted
Post Partisan
Post Partisan

Re: check value in label then make perform code

@iAm_ManCat,

So when the warning is displayed...do they exit  out of the "onChange" event automatically ?

 

Dave

Highlighted
Post Partisan
Post Partisan

Re: check value in label then make perform code

@UdayAdhikari 

@iAm_ManCat,

Sorry did not explain myself well.

I have a table(tbl_Tasks) with the values of the "Change Status" dropdown displayed.

When a person makes a choice in the dropdown, i'm doing a check to make sure 2 tasks are not open at the same time.

 

I have the lbl_Open_Chk display either 0 or 1

So basically what I need to make sure is , no 2 tasks open at the same time.

sorry had to black out some information with the arrows.

powerapps status.jpg

Thanks

Dave

Highlighted
Resolver III
Resolver III

Re: check value in label then make perform code

@DAVIDPOWELL - yes, that's true! OnChange event is triggered only once per value change in the dropdown so warning is displayed and exits out of that event.

Highlighted
Post Partisan
Post Partisan

Re: check value in label then make perform code

ok, one last question.

If they Select "Open" how do I automatically change the value back to:

dwn_ChangeStatus.Selected.Value = "In Progress" after the warning ?

 

Thanks

Dave

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,399)