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?
Regards,
Alois
Solved! Go to Solution.
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,
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.
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,
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.
Do you (or anyone) have any idea the reason for this and how to circumvent it?
Regards,
Alois
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
209 | |
194 | |
82 | |
58 | |
38 |
User | Count |
---|---|
303 | |
249 | |
120 | |
83 | |
55 |