创建dynamics CRM client-side (八) - 获取attribute的值 和 设置disable
大家可以用下面的方式来获取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