abrufen Ich kann alle Textfeld Wert von Konto abrufen und den Wert auf Textfeld in Kontakt festlegen. Aber ich habe invalid type
, wenn ich versuchte, den gleichen Code für Optionsfeld zu verwenden.Wie Option Option Wert aus Lookup-Feld mithilfe von Javascript, OData-Endpunkt
In diesem Fall ist parentcustomerid
ein Nachschlagefeld in Contact
, die nach Account
sucht. new_GroupofAccount
ist Option festgelegt Schema-Name in Account
und new_groupofaccountcontact
ist Option festgelegt Feldname in Contact
. Was ich erreichen möchte, wenn parentcustomerid
Wert erhalten hat, möchte ich den Wert der in Account
eingestellten Option in new_groupofaccountcontact
in contact
widerspiegeln. Beide Optionssatzfelder verwenden denselben globalen Optionssatzwert.
Das ist mein js Code:
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);
}
}
sehr schätzen für jede hilft. Danke im Voraus.
versuchen Sie '.setValue (data.d.new_GroupofAccount.Value);' – ASpirin