PowerApps 中的 Defaults 函数Defaults function in PowerApps

返回数据源的默认值。Returns the default values for a data source.

说明Description

使用 Defaults 函数可预填充数据输入表单,简化操作。Use the Defaults function to pre-populate a data entry form, making it easier to fill.

这个函数返回包含数据源默认值的记录This function returns a record that contains the default values for the data source. 如果数据源中的没有默认值,则不会有这个属性。If a column within the data source doesn't have a default value, that property won't be present.

数据源中提供的默认信息量可能不同,甚至可能不提供任何信息。Data sources vary in how much default information they provide, including not providing any at all. 使用集合或不支持默认值的其他数据源时,Defaults 函数会返回 empty 记录。When you work with a collection or another data source that doesn't support default values, the Defaults function will return an empty record.

结合使用 Defaults 函数和 Patch 函数可创建记录You can combine the Defaults function with the Patch function to create a record.

语法Syntax

Defaults( DataSource )Defaults( DataSource )

  • DataSource – 必需。DataSource – Required. 需要其默认值的数据源。The data source for which you want default values.

示例Examples

公式Formula 说明Description 结果Result
Defaults( Scores )Defaults( Scores ) 返回 Scores 数据源的默认值。Returns the default values for the Scores data source. { Score: 0 }{ Score: 0 }