アカウントからテキストフィールド値を取得し、値をContactのテキストフィールドに設定できます。しかし、私はオプションのフィールドに同じコードを使用しようとしたときinvalid type
を得た。Javascript、ODataエンドポイントを使用してルックアップフィールドからオプション設定値を取得する方法
この場合、parentcustomerid
はContact
のルックアップフィールドで、Account
にルックアップします。 new_GroupofAccount
はオプション設定スキーマ名はAccount
、new_groupofaccountcontact
はオプション設定フィールド名はContact
です。もしparentcustomerid
が値を持っていたら、Account
に設定されたオプションの値をnew_groupofaccountcontact
のcontact
に反映させたい。どちらのオプション設定フィールドも同じグローバルオプション設定値を使用しています。
これは私のjsのコードです:
function getOptionSet() {
var accountId = null;
try {
accountId = Xrm.Page.getAttribute("parentcustomerid").getValue()[0].id;
} catch (ex) {
accountId = null;
}
if (accountId !== null) {
var req = new XMLHttpRequest();
var url = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + accountId + "')?$select=new_GroupofAccount";
req.open("GET", url, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (req.readyState == 4) {
var data = JSON.parse(req.responseText);
// use data.d.WebSiteURL
Xrm.Page.getAttribute("new_groupofaccountcontact").setValue(data.d.new_GroupofAccount);
}
};
req.send(null);
}
}
任意の助けのために大幅に感謝しています。前もって感謝します。
'.setValue(data.d.new_GroupofAccount.Value);' – ASpirin