[英]How to Clone an custom entity in dynamics 365 using javaScript
[英]display related entity in Dynamics 365 and JavaScript
我創建了具有3個字段的實體:
我創建了JS代碼以顯示或編輯這些字段,但是有沒有辦法使用實際實體中的formContext顯示來自Account實體的數據?
function test(executionContext) {
var formContext = executionContext.getFormContext();
//text
var text = formContext.data.entity.attributes.getByName('new_text').getValue();
text.setValue("new text");
//number
var number = formContext.data.entity.attributes.getByName('new_number').getValue();
number.setValue(5);
//id field for another entity
var number = formContext.data.entity.attributes.getByName('new_accountid').getValue();
//my ideal solution would've look like this, but it doesn't working
number.getParent().attributes.getByName('account_name').getValue();
}
與帳戶的關系是一個查找字段。 如何獲取/設置查找屬性值?
您可以通過以下方式獲得其價值:
var lookup = new Array();
lookup = formContext.getAttribute("Lookup Field Name").getValue();
if (lookup != null) {
var name = lookup[0].name;
var id = lookup[0].id;
var entityType = lookup[0].entityType;
}
您可以通過以下方式設置其值:
formContext.getAttribute("Lookup Field Name").setValue([{ id: recordid, name: recordname, entityType: entityname}]);
如果只想以當前實體形式顯示該查找記錄中的其他屬性,則可以使用當前實體中該查找實體的快速查看形式 。
如果要從“帳戶查找記錄”中檢索不同的屬性並將其設置為當前實體表單字段,請使用Xrm.Webapi
來獲取它並設置值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.