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 5,514
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
    5,514 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans