Hello
I have an edit form that I have a text box for the weather on
The idea is that the user presses the weather icon and the app will get the current weather and update the box
I am doing this using
Set(varLocation, Text(Location.Latitude)&","&Text(Location.Longitude));
UpdateContext({Weather: MSNWeather.CurrentWeather(varLocation, "Metric")});
Set(varCurrentDiaryEntry, Patch(varCurrentDiaryEntry, {Field_2: Weather.responses.weather.current.cap}));
This code is only invoked when the icon is clicked, but as soon as this exists, my screen no longer works
There are no errors
What is the problem?
I have also tried this on a button outside of the edit form
Paul
Solved! Go to Solution.
Hi @paulinuk ,
Firstly, if you are trying to set a Variable, you should be able to do this
With(
{
wWeather:
MSNWeather.CurrentWeather(
Location.Latitude & "," & Location.Longitude,
"Metric"
)
},
Set(
varCurrentDiaryEntry,
{Field_2: wWeather.responses.weather.current.cap}
)
);
Your output would then be
varCurrentDiaryEntry.Field_2
and simply sets a Variable. What happens to your screen?
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
Hi @paulinuk ,
Firstly, if you are trying to set a Variable, you should be able to do this
With(
{
wWeather:
MSNWeather.CurrentWeather(
Location.Latitude & "," & Location.Longitude,
"Metric"
)
},
Set(
varCurrentDiaryEntry,
{Field_2: wWeather.responses.weather.current.cap}
)
);
Your output would then be
varCurrentDiaryEntry.Field_2
and simply sets a Variable. What happens to your screen?
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
Thanks
Yes this is what I am trying to do but as soon as I put this code into an icon inside or a button outside the form the screen doesnt work at all
I have also seen the message below which could be related but I have no idea how to resolve
Hi @paulinuk ,
What has the Item of the Form got to do with this? What is the code on there?
This error happens when I put the code you showed above in a button outside of the form
Im wondering if the designer is trying to evaluate this code at design time when the variable is nul?
The error you have posted refers to the Item of the Form - what is the code there?
I have also tested the code I posted (I also use this function) and it is valid whether inside or outside a form as it does not refer to anything in the form.
I have changed this to be the best practice and the error has gone again, it seems to come up every now and then
My current code for the Item of form is
LookUp('Site Diary Entries',ID=varCurrentDiaryEntryId)
The problem now is that I cant use your logic as that updates a variable, which is now not being used as the Item for this form due to this error?
Hi @paulinuk ,
But the Variable you are setting on the weather is varCurrentDiaryEntry which is actually a Table with Field2 containing the weather. The Variable in your Form Item is CurrentDiaryEntryId - how is that stopping you using the weather code?
Because I thought I had to update the exact variable that the form is bound to.
The weather code is working fine now
When the user clicks on a weather button on the edit form I want to change the value of the Weather text box to be the weather returned from MSN
I’ve tried loads of different ways but nothing updates the text box on my form do I need to do something to force the box to refresh?
User | Count |
---|---|
161 | |
86 | |
68 | |
63 | |
62 |
User | Count |
---|---|
212 | |
146 | |
92 | |
81 | |
68 |