[英]Dynamics 365. Field value (javascript)
如何使用JavaScript在Dynamics 365中獲取字段值? 在瀏覽器控制台函數Xrm.Page()
返回未定義。 當我嘗試獲取諸如
Xrm.Page.getAttribute("new_city").getValue();
在瀏覽器控制台中收到錯誤:
無法獲取未定義或空引用的屬性“ getValue”
有兩種方法可以解決此問題
在“開發人員工具”窗口右上角的“目標”下拉列表中,切換到“客戶端API包裝器”。 然后,您應該可以使用javascript代碼訪問表單。 您的語法正確。
在代碼的開頭加上索引為0的框架
例:
var city = frames[0].Xrm.Page.getAttribute('bah_city').getValue();
祝好運!
Xrm.Page()
可能不是存在的方法。 請嘗試Xrm.Page
。
對於Xrm.Page.getAttribute("new_city")
,您確定嗎:
您的代碼: Xrm.Page.getAttribute("new_city").getValue();
應該管用。
確保使用的名稱與字段屬性中顯示的名稱完全相同。
其他答案中給出了可能的原因。
為避免錯誤,請始終使用null檢查。
if(Xrm.Page.getAttribute("new_city") != null)
var city = Xrm.Page.getAttribute("new_city").getValue();
如果您在標題中使用此字段,請使用以下命令:
Xrm.Page.getAttribute("header_new_city").getValue();
如果要在業務流程中使用此字段,請使用以下命令:
Xrm.Page.getAttribute("header_process_new_city").getValue();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.