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 III
Super User III

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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (71,031)