cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alois
Helper III
Helper III

Error handling for Live calculation of BingMaps Distance and Time based on user input

Hi All,

I have an edit form view that takes into 2 locations - Vendor Address and Destination. Based on the user input, it will calculate the distance and time live in the distance (km) and estimated duration (mins) fields. The form works. However, it throws up an error because calculation of distance and time fails before the user could complete inputting the location fields. Are there any ways to disable the error?

Alois_0-1603812577531.png
Regards,
Alois

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Alois ,

The reason why you met this problem is that:

before you finish entering location in that two textinputs, BingMaps.GetRoute function have started to calculate location based on data in these two textinputs.

Since you haven't finished entering location, so BingMaps.GetRoute could not get right location.

 

To add this problem I suggest you add a justification by using BingMaps.GetLocationByPoint function or BingMaps.GetLocationByAddress function.

 

Could you tell me whether you enter Address or Point in DataCardValue56 and DataCardValue60?

If you enter  Address, you could use formula like this:

If(
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput1.Text}))&&
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput2.Text})),
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

If you enter  Point, you could use formula like this:

If(
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue56.Text,",")).Result,
                                      Last(Split(DataCardValue56,",")).Result
                                      )
         )&&
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue60.Text,",")).Result,
                                      Last(Split(DataCardValue60,",")).Result
                                      )
         )
,
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

 

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

4 REPLIES 4
timl
Super User
Super User

Hi @Alois 

One way to avoid this error is to only calculate the distance if the input values are not blank.

You would change your formula as follows..

 

If(DataCardValue56.Text <> "" && DataCardValue60.Text <> "",
   Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2),
   0
)

Hi @timl,
It returns me an error in evaluating the expression. Am I doing it right? 

The reference to datacardvalue are correct.

Alois_0-1603846084117.png

Regards,
Alois

 

Hi @Alois ,

The reason why you met this problem is that:

before you finish entering location in that two textinputs, BingMaps.GetRoute function have started to calculate location based on data in these two textinputs.

Since you haven't finished entering location, so BingMaps.GetRoute could not get right location.

 

To add this problem I suggest you add a justification by using BingMaps.GetLocationByPoint function or BingMaps.GetLocationByAddress function.

 

Could you tell me whether you enter Address or Point in DataCardValue56 and DataCardValue60?

If you enter  Address, you could use formula like this:

If(
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput1.Text}))&&
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput2.Text})),
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

If you enter  Point, you could use formula like this:

If(
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue56.Text,",")).Result,
                                      Last(Split(DataCardValue56,",")).Result
                                      )
         )&&
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue60.Text,",")).Result,
                                      Last(Split(DataCardValue60,",")).Result
                                      )
         )
,
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

 

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

Hi @v-yutliu-msft ,

The solution worked but was shortlived. Users were complaining of errors popping up as they keyed in the addresses. It seems like BingMaps continues to actively calculate the distance and duration despite having accounted for the if !empty cases.

Alois_0-1605607667819.png

Do you (or anyone) have any idea the reason for this and how to circumvent it?

Regards,
Alois

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,062)