web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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
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
I have the same question (0)
  • sandeepc Profile Picture
    on at
     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?
  • Verified answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    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

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

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans