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

OnVisible variables not always working

Hello,

I have a bit of a problem:

In my form on 8 of the screens, I have a different toggle on each screen, with Yes/No.

If its a Yes (true), it updates the Status dropdown to 'Requires further review'

If its a No (false), it updates the Status dropdown to 'No further review required'

 

I then have a hidden label on the screen, which is looking at the value of dropdown (DataCardValue162) on its text property:

DataCardValue162.Selected.Value = "Requires further review"

 Then on the OnVisible of that screen I have:

If(Lbl_ReviewYes1.Text = "true", Set(ReviewYes1, Lbl_ReviewYes1.Text));

 

Then on on Screen2 I have the same set up , but looking at DataCardValue163, and the Lbl_ReviewYes2, is being set to ReviewYes2 and so on

 

I noticed if one of the Reviews are set to Requires further review, the label which is hidden, displays true, so that part of the logic is working, but when navigating away to other screens, it appears the OnVisible variable doesn't always get set.

 

So I thought the user is clicking the next button too quickly, so I've put a timer on the screen to show the next button 6 secs later.... I thought this fixed the issue, but didn't.

 

The problem I have is, if any 1 of the 8 screens have set yes to Requires Review, the code I have navigates all users to a Final Review screen, but sometimes what is happening is even though a further review is required, it navigates to the final screen as though it doesn't require a review and this is a problem.

 

I don't believe my next button code is where the problem is, and I'm fairly certain it's to do with the OnVisible variable set at each screen not always triggering.

 

Any ideas how I can fix/troubleshoot this please?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Hi @G99 ,

Please notice one point:
The screen's OnVisible property will only be triggered when you load the screen.

So even if you change the selected value of DataCardValue162 later, this property will not the triggered. So value of ReviewYes1 will not refresh automatically based on the selected value of DataCardValue162 .

I suggest you set like this:

1)set the toggle's OnCheck:

Set(ReviewYes1,true)

set the toggle's OnUncheck

Set(ReviewYes1,false)

set the toggle's OnChange:

Reset(DataCardValue162)

2)DataCardValue162's Default:

If(Toggle1.Value,"Requires further review","No further review required")

3)label's Text:

DataCardValue162.Selected.Value = "Requires further review"

4)inset a Timer

set the Timer's OnTimerEnd:

If(Lbl_ReviewYes1.Text = true, Set(ReviewYes1, Lbl_ReviewYes1.Text));

set the Timer's Duration:

3000   //3s

set the Timer's AutoStart:

true

//do not use screen's OnVisible to set a variable value based on label's Text.

Loading label's Text needs time, which may lead to setting the variable with wrong data.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Highlighted
Frequent Visitor

Hello @G99 ,

 

Here  is a suggestion for you:


- Rather than setting up the OnVisible property of each screen, set it on App Onstart property

Concurrent(
Set(ReviewYes1,lbl_ReviewYes1.Text),
Set(ReviewYes2,lbl_ReviewYes2.Text),
Set(ReviewYes3,lbl_ReviewYes3.Text) // and so on for the rest...

)

This will actually reference any text in the label and amend it to the variable, and this will be done across all screens.

Let me know if you need more clarifications
--
Accept this as a solution if it works...

Highlighted
Community Support
Community Support

Hi @G99 ,

Please notice one point:
The screen's OnVisible property will only be triggered when you load the screen.

So even if you change the selected value of DataCardValue162 later, this property will not the triggered. So value of ReviewYes1 will not refresh automatically based on the selected value of DataCardValue162 .

I suggest you set like this:

1)set the toggle's OnCheck:

Set(ReviewYes1,true)

set the toggle's OnUncheck

Set(ReviewYes1,false)

set the toggle's OnChange:

Reset(DataCardValue162)

2)DataCardValue162's Default:

If(Toggle1.Value,"Requires further review","No further review required")

3)label's Text:

DataCardValue162.Selected.Value = "Requires further review"

4)inset a Timer

set the Timer's OnTimerEnd:

If(Lbl_ReviewYes1.Text = true, Set(ReviewYes1, Lbl_ReviewYes1.Text));

set the Timer's Duration:

3000   //3s

set the Timer's AutoStart:

true

//do not use screen's OnVisible to set a variable value based on label's Text.

Loading label's Text needs time, which may lead to setting the variable with wrong data.

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted

hi @v-yutliu-msft 

 

Thanks for your detailed response.

Just to clarify does @Silvester  workaround not work, I haven't tested it but I was implementing this yesterday evening.

 

@v-yutliu-msft  You are right it appears the OnVisible Screen variable does need time, if I navigate to the screen, then away and then back to the screen it will always set the variable, but otherwise its hit and miss.

 

Highlighted

Hi @G99 ,

So have you tried my solution?

Does using timer make any difference?

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

hi @v-yutliu-msft 

 

I haven't yet, I was hoping if you can clarify if the other solution, suggested by the other helper would work?

Highlighted
Frequent Visitor

Hi @G99 ,

If you are still using my approach, the next step you need to do is to set the toggle true or false parameters to the various labels you provisioned for that purpose. 

if(toggle.value="yes",lbl1.text="Review Required",lbl1.text="Review not required")// Do the same for the rest of the screens with the differents labels

I used this approach because, that it aligns with the logic you are trying to implement.

A great to achieve your goal also is what @v-yutliu-msft is suggesting...

Highlighted

Hi @G99 ,

Since I do not know every details of your app, so I could not directly justify whether our solutions work for you.

I suggest you try the solution that @Silvester provided and the solution that I provided above by yourself.

If there's still any problem, please point out.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

HI @v-yutliu-msft @Silvester 

 

 

Thank you both, I will try both the suggestions and see which works best.

I will look to report back tomorrow, or Monday the latest, if I encounter further issues with either solution

 

Thank you so much for helping me with this

Highlighted

HI @v-yutliu-msft 

 

I had same issues using @Silvester probably me not setting it properly.

 

@v-yutliu-msft 

I've used your suggestions, and removed the variable OnVisible of the screen, the only 2 things I have changed is the toggle OnCheck:

 

Set(ReviewYes1,true)

and OnUnCheck

Set(ReviewYes1,false)

 

This seems to be setting the variable I need to reference in my other screens. I need to test everything else but I dont think I need to change anything else... i'll report back once properly tested

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,253)