cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver II
Resolver II

Circular Reference?

Hello everyone,

 

I am having this issue, I have:

  • A Gallery (Gallery1) with controllers
    • One TextInput (TextInput1)
    • One TextBox (TextBox1)
  • Independent Controllers
    • One TextBox (TextBox2)
    • One Other Gallery (Gallery2) for Calculation

This is how I want them to work:

The user will enter input for Gallery1.TextInput1 >>> TextBox2: will process input (TextInput1.Text) from Gallery1.TextInput1, then do some calculations >>> Gallery2 will use the calculations from TextBox2 to do a load of other calculations >>> Gallery1.TextBox1: will do a Sum from the calculations of Gallery2.

 

I have a circular reference error from this approach.

 

What I do to fix this problem, for now, is to use a Temp variable:

 The user will enter input for Gallery1.TextInput1 >>> Gallery1.TextInput1.OnChange will UpdateContext({ Temp: TextInput1.Text}) >>> TextBox2 will process Temp instead of TextInput1.Text >>> [Same as above]

 

What I want to achieve is to get Gallery1.TextBox1 updated for every change made from TextInput1. OnChange can only be fired when the TextInput1 unfocused. So I don't really want to use this.

 

Anyone has any better idea to solve this.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

The solution I am using is to create a Timer(duration: 100ms) for each item in Gallery1 and another controller to hold the Input of Gallery.Input1 (TextBox3). The timer will keep TextBox3 updated with TextBox1 by using UpdateContext. Then TextBox2 can use TextBox3 to do the work. 

View solution in original post

7 REPLIES 7
Highlighted
Community Champion
Community Champion

Hi

 

Hope I understand your ideas.

Use Collection & Sum:

1. Gallery1.TextInput1.OnChange / OnSelect:

- Collect(TableX, {Qty: Gallery1.TextInput1.Text*10})     [Assume your calculation is multiplication]

2. TextBox1: Sum(TableX, Qty)

 

UpdateContest is useful for holding temporary context variable ONCE only but

Collection is the best function to temporary holding records. (for me, Collection is one of the best function)

 

Hope it helps.

TQ

 

hpkeong
Highlighted

Thank you hpkeong,

I tried your suggestion but it doesn't help or you misunderstand my idea.

 

What I want to get is that the Gallery1.TextBox1 will get live update from TextInput1 after the value of TextInput1 processed by Gallery2 and TextBox2

Highlighted
Community Champion
Community Champion

Hi

 

Can you please give a sample format so that can understand better?

I try to have Value from TextInput1 calcualted behind the screen instead of TextBox2 and Gallery2.

With sample, maybe I can understand better.

THanks

hpkeong
Highlighted
Community Champion
Community Champion

Hi

 

I was wondering, instead of passing values to Gal2, TextBox2 and back to TextBox1, all calculations / loading can be accomplished by setting formula within Collection & as well as final TextBox1.

I really wish to know your real scenario to learn together how to resolve circular ref problem.

hpkeong
Highlighted

It's a heavy calculation so I decided to create other controllers.

TextBox2 used to to do pre-calculation which is pretty complicated. What it does is to create a desired filter.

Then the Gallery2 will use that filter to get a list of items (usually hundreds of recs), in each item, I have to make 2 more calculations.

Finally, the TextBox1 will Sum the calculations from all items.

Highlighted

The solution I am using is to create a Timer(duration: 100ms) for each item in Gallery1 and another controller to hold the Input of Gallery.Input1 (TextBox3). The timer will keep TextBox3 updated with TextBox1 by using UpdateContext. Then TextBox2 can use TextBox3 to do the work. 

View solution in original post

Highlighted
Community Champion
Community Champion

Hi

 

Glad to hear that you got your problem solved.

Maybe different problems different approach.

Just sharing that Collection will not hold memory and will be cleared when apps is closed.

 

Have a good day.

 

hpkeong

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 (9,772)