Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Retrieve value and update in another entity

(0) ShareShare
ReportReport
Posted on by 5,476
Hi Team,
 
I have a requirement to retrieve a exchane rate value from currency entity and update that value in opportunity entity.
using xrm.web.api.retrieve multiple
 
how can i achieve this ??? any links or steps will be helpful
 
 
Thanks
Sandeep
  • Verified answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    Retrieve value and update in another entity
    Hi Partner,
    Based on your description and code, you have decided to use exchange rate of eruo, Right?
    Why not use it's guid to retrieve it directly?
    Example Code:
    function getEuroExchangeRate(executionContext) {
        var formContext = executionContext.getFormContext();
        //Retrieve record
        Xrm.WebApi.retrieveRecord("transactioncurrency", "e97e1a46-4e59-e811-8148-000d3a06499e", "?$select=exchangerate").then(
            function success(result) {
                console.log(result);
                // Columns
                var transactioncurrencyid = result["transactioncurrencyid"]; // Guid
                var exchangerate = result["exchangerate"]; // Decimal
                var exchangerate_formatted = result["exchangerate@OData.Community.Display.V1.FormattedValue"];
    
                //update field
                formContext.getAttribute("abc_euroexchangerate").setValue(exchangerate);//abc_euroexchangerate should be logic name of the field
    
            },
            function (error) {
                console.log(error.message);
            }
        );
    
    }
    Note:
    This tool--Dataverse REST Builder, it can help you build code easily:
     

    I hope you can mark my answer verified if it is helpful! If you have any questions, please feel free to contact me.
    Regards,
    Leah
  • sandeepc Profile Picture
    5,476 on at
    Retrieve value and update in another entity
     function getEuroExchangeRate(executionContext) {
       var formContext= executionContext.getformContext();
       try {
           var results =  Xrm.WebApi.retrievemultiplerecords("currency", "?$select=exchangerate&$filter=name eq '" + euro + "'");
          // Xrm.WebApi.retrieveRecord(entityLogicalName, id, options).then(successCallback, errorCallback);
           if (results.entities.length > 0) {
               var result = results.entities[0];
              // exchangerate = result["exchangerate"];
                   formContext.getAttribute("abc_euroexchangerate").setValue("result["exchangerate"]");
           }
       }
       catch (error) {
           console.error(error.message);
           return exchangerate;
       }
    }
     
    is this correct?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 671 Super User 2025 Season 1

#2
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 167 Super User 2025 Season 1

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 138 Most Valuable Professional

Product updates

Dynamics 365 release plans