I've added a IFrame to a parent entity form. It gets all the parents children because the child knows its parent id. But the child has a lookup field, msdyn_tasktype.
In the list of children I don't get the field straight out... its actually "hiding" at _msdyn_tasktype_value
1) Why is this?
2) How can I get the value of the tasktype, the _msdyn_tasktype_value contains the GUID?
If I was on a page of the child I would get it by; Xrm.Page.getAttribute('<FIELD_NAME>').getValue()[0]. But I'm on the parent page listing all the children and I would like to output the tasktype as it is a string value.
*This post is locked for comments
Thanks Aric, that did the trick.
Hi,
Are you getting the values using webapi?
Field names that are specified as _fieldname_value have only a Guid.
If you are using webapi, you will need to add the following to your function call in order to get the formatted values in option sets and the name/logical name in lookup controls:
req.setRequestHeader(“Prefer”, “odata.include-annotations=\”*\””);
Example:
var accountId = result["_accountid_value"];
var accountName = result["_accountid_value@OData.Community.Display.V1.FormattedValue"];
var accountLogicalName = result["_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
Hope this helps.
Hi,
Use this function to get the lookup data by passing each child record,
///<summary>
/// Gets the lookup attribute value
///</summary>
getLookupAttributeValue = function (result, attributeName) {
if (result !== undefined && result !== null) {
if (result["_" + attributeName + "_value"] !== undefined && result["_" + attributeName + "_value"] !== null) {
return {
Id: result["_" + attributeName + "_value"],
LogicalName: (result["_" + attributeName + "_value@Microsoft.Dynamics.CRM.lookuplogicalname"] !== undefined && result["_" + attributeName + "_value@Microsoft.Dynamics.CRM.lookuplogicalname"] !== null) ? result["_" + attributeName + "_value@Microsoft.Dynamics.CRM.lookuplogicalname"] : null,
Name: (result["_" + attributeName + "_value@OData.Community.Display.V1.FormattedValue"] !== undefined && result["_" + attributeName + "_value@OData.Community.Display.V1.FormattedValue"] !== null) ? result["_" + attributeName + "_value@OData.Community.Display.V1.FormattedValue"] : null
};
}
}
return null;
}
Assume you are using Dynamics 365 V8.2 else you will not get LogicaName property from results.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156