大家可以用下面的方式来获取attribute的值
formContext.getAttribute("address1_shippingmethodcode").getText()
可以用setDisabled 来disable相关联的值
formContext.getControl("address1_freighttermscode").setDisabled(true);

// Converting functions to Namespace Notation
var Sdk = window.Sdk || {};
(
function () {
this.formOnLoad = function (executionContext) {
var formContext = executionContext.getFormContext();
var firstName = formContext.getAttribute("firstname").getValue();
alert("Hello World " + firstName);
};
this.shippingMethodOnChange = function (executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.getAttribute("address1_shippingmethodcode").getText() === "FedEx") {
formContext.getControl("address1_freighttermscode").setDisabled(true);
} else {
formContext.getControl("address1_freighttermscode").setDisabled(false);
}
}
}
).call(Sdk);

更多controls 可以通过微软官方文档来了解
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls
本文介绍在PowerApps中如何使用formContext.getAttribute和formContext.getControl方法来获取和设置表单属性值及控制状态。通过具体示例展示了如何根据shipping method的变化禁用或启用freight terms的选择。
13万+

被折叠的 条评论
为什么被折叠?



