Sunday, November 11, 2018

C# Code to Call getConsolidatedExchangeRate via Web Service

 

C# code to call getConsolidatedExchangeRate via web service.
 

This API is used to get the exchange rates between the root-parent and child subsidiaries. Note that this API can only be used in NetSuite One World Account. The value pulled out by the operation is from the Exchange Rates table on Lists > Accounting > Consolidated Exchange Rates.

            RecordRef fromSubsidiary = new RecordRef();
            RecordRef toSubsidiary = new RecordRef();
            RecordRef period = new RecordRef();

            fromSubsidiary.internalId = "13";
            toSubsidiary.internalId = "1";
            period.internalId ="150";

            ConsolidatedExchangeRateFilter  pfilters = new ConsolidatedExchangeRateFilter();
            pfilters.period = period;
            pfilters.fromSubsidiary = fromSubsidiary;
            pfilters.toSubsidiary = toSubsidiary;
            GetConsolidatedExchangeRateResult presult = _service.getConsolidatedExchangeRate(pfilters);


            if( presult.status.isSuccess){
               
               
                  ConsolidatedExchangeRate[] list = new ConsolidatedExchangeRate[presult.consolidatedExchangeRateList.Length];
                  list = presult.consolidatedExchangeRateList;
                  var rate=list[0].currentRate ;
                  Debug.Write("current rate" + rate.ToString());

               
                }
           

Note: To get the internal ID of a period, make sure SHOW INTERNAL IDS is enabled by navigating to Home > Set Preferences > General tab. Once enabled, a column for Internal ID will be displayed when viewing list of periods. Another way is to check the internal ID parameter of the period on the URL- ex: 

https://system.netsuite.com/app/setup/period/fiscalperiod.nl?e=T&id=140

No comments:

Post a Comment