'Problem with setting Label value empty when the apps run
In my screen I have several textbox. There is a save button. After clicking the button the below formula executes to save data to the database.
Patch(
Customer,
Defaults(Customer),
{
FirstName: txtFirstName.Text,
LastName: txtLastName.Text,
Address: txtAddress.Text,
City: drpCity.Selected.Id,
PostCode: txtPostCode.Text,
Telephone: txtTelephone.Text,
Mobile: txtMobile.Text
}
);
Reset(txtFirstName);
Reset(txtLastName);
Reset(txtAddress);
Reset(drpCity);
Reset(txtPostCode);
Reset(txtTelephone);
Reset(txtMobile);
UpdateContext({varMessage: "Customer saved successfully."})
After saving data to the database, I am stroing a successful message to a local variable. The local variable is bound to a label field to show the successfull message. Now the problem is at first time when the screen run, the label is empty and on button click data is saved and successful message is shown to the label. But if I run the screen again, the label holds the previous value. Now I want to empty the local variable when the screen runs. So at OnVisible event I wrote
varMessage = ""
but it does not work.
Solution 1:[1]
Add a formula to clear your variable's value on the screen OnVisible :
UpdateContext({varMessage: Blank()})
So when you go to this screen, this value his always initialized as empty.
It has nothing to do with but I suggest you to use Form component to create rows and simplify your code. This article can help you : https://docs.microsoft.com/en-us/power-apps/maker/canvas-apps/controls/control-form-detail
Have a good day,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nackoo |
