Xrm.WebApi.retrieveRecord("opportunity", opportunityID, "?$select=_transactioncurrencyid_value").then(
function success(result) {
console.log(result);
// Columns
var opportunityid = result["opportunityid"]; // Guid
var transactioncurrencyid = result["_transactioncurrencyid_value"]; // Lookup
var transactioncurrencyid_formatted = result["_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue"];
var transactioncurrencyid_lookuplogicalname = result["_transactioncurrencyid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
var lookup = [];
lookup[0] = {};
lookup[0].id = transactioncurrencyid;
lookup[0].entityType = transactioncurrencyid_lookuplogicalname;
lookup[0].name = transactioncurrencyid_formatted;
// Get and Set New Lookup
formContext.getAttribute("transactioncurrencyid").setValue(lookup);
},
function (error) {
console.log(error.message);
}
);
function getOpportunityCurrency(executionContext)
{
var formContext = executionContext.getFormContext();
var opportunityID = formContext.getAttribute("opportunityid")[0].id;
Xrm.WebApi.retrieveRecord("opportunity", opportunityID, "?$select=_transactioncurrencyid_value").then(
function success(result) {
console.log(result);
// Columns
var opportunityid = result["opportunityid"]; // Guid
var transactioncurrencyid = result["_transactioncurrencyid_value"]; // Lookup
var transactioncurrencyid_formatted = result["_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue"];
var transactioncurrencyid_lookuplogicalname = result["_transactioncurrencyid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
alert("");
},
function(error) {
console.log(error.message);
}
);
}
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156