Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archive)
Answered

Retrieve value and update in another entity

(0) ShareShare
ReportReport
Posted on by 5,005
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,005 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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard > Microsoft Dynamics CRM (Archive)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans