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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

retrieve "transactioncurrencyid" from parent "opportunity"

(1) ShareShare
ReportReport
Posted on by 448
Hi all
I'm trying to retrieve the /transactioncurrencyid/ from parent /opportunity/.
This is my Javascript lines:
        var strValuta = parent.Xrm.Page.getAttribute(/transactioncurrencyid/).getValue();
        var formattedCurrencyId = strValuta[0].id;
        var formattedCurrencyName = strValuta[0].name;
        alert(strValuta + / - / + formattedCurrencyId + / - / + formattedCurrencyName);

In my parent opportunity the currency is CHF but in the alert I retrieve the EUR that is not correct.
Can somebody correct my javascript or suggest me some alternate idea to retrieve the correct currency in my child table?
Thanks in advance
I have the same question (0)
  • Verified answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    Hi,
    Your description: from parent /opportunity...in my child table..
    Will this parent opportunity be a lookup field on a child table?
    If so, you can get opportunity id, then use this id to retrieve this record to get transactioncurrencyid value.
    Please refer to this example code
    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);
                    }
            );
    
    }

    I hope you can mark my answer verified if it answer your question! If you have any questions, please feel free to contact me.
    Regards,
    Leah
  • DiePic Profile Picture
    448 on at
    Hi  Leah Ju   and thanks for the reply.
    It's exactly what I was looking for.
    Now with this javascript
            if (!strNumOpportunita) {
              formContext.getAttribute("ath_name").setValue(NumOpportunita);
              formContext.getAttribute("transactioncurrencyid").setValue([{ id: strValuta, entitàType: "transactioncurrency" }]);
            }

     
    my value columns are correct, but how can I also change the name of the exposed "value" field?

    ​​​​​​​
  • Verified answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    Hi ,
    The image is not loading.
    You are trying to update the 'transactioncurrencyid' value on the child table, right?
    This is one lookup column, you need set it's value with id, name and entity type.
    It should be like:
            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);
                    }
            );
     
     
     
  • DiePic Profile Picture
    448 on at
    now it's working .... thank you very much Leah Ju

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 166

#2
ManoVerse Profile Picture

ManoVerse 149 Super User 2026 Season 1

#3
Zhilan Profile Picture

Zhilan 55

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans