当应用程序运行时,设置标签值空的问题

发布于 2025-01-20 11:33:12 字数 790 浏览 3 评论 0 原文

在我的屏幕中,我有几个文本框。有一个保存按钮。单击按钮后,以下公式执行以将数据保存到数据库。

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."})

将数据保存到数据库之后,我将成功的消息传递到本地变量。本地变量绑定到标签字段以显示成功的消息。现在,问题是在屏幕运行时首次,标签为空并且单击按钮单击数据,并将成功的消息显示给标签。但是,如果我再次运行屏幕,标签将保留上一个值。现在,我想在屏幕运行时清空本地变量。因此,在易见的活动中,我写了,

varMessage = ""

但它行不通。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尬尬 2025-01-27 11:33:12

添加一个公式以在屏幕上清除您的变量的值:

UpdateContext({varMessage: Blank()})

因此,当您进入此屏幕时,此值始终将其初始化为空。

它与它无关,但我建议您使用表单组件来创建行并简化代码。本文可以为您提供帮助:

有美好的一天,

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://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/controls/control-form-detail

Have a good day,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文