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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

OData DataServiceCollection Performance Issues

(0) ShareShare
ReportReport
Posted on by 300

I am currently creating trade agreement journals in D365 through an OData endpoint. I am now load testing it as I have to account for creating up to 120,000 journals. 

To populate the DataServiceCollection in the below loop is taking around 37 minutes when I would expect it to be taking at most a couple of seconds. I assume it is firing off some NotifcationChanged event when the property is set but I am not sure.

The code I am using is below, which successfully updates a small amount of records.

DataServiceCollection journals = new DataServiceCollection(context);
OpenSalesPriceJournalLine journal;

foreach (var agreement in agreements)
{
    journal = new OpenSalesPriceJournalLine();
    journals.Add(journal);

    journal.DataAreaId = dataAreaId;
    journal.TradeAgreementJournalNumber = journalNumber;
    journal.LineNumber = index;
    journal.PriceApplicableFromDate = fromDate;
    journal.ToQuantity = agreement.QUANTITYAMOUNTTO;
    journal.Price = agreement.CalculationAmount;
    journal.PriceApplicableToDate = toDate;                   
    journal.PriceCurrencyCode = agreement.CURRENCY;
    journal.ItemNumber = agreement.ITEMRELATION;
    journal.FromQuantity = agreement.QUANTITYAMOUNTFROM;
    journal.QuantityUnitSymbol = agreement.UNITID;
    journal.SalesPriceQuantity = agreement.PRICEUNIT;
    journal.SalesLeadTimeDays = agreement.DeliveryTime;
    journal.FixedPriceCharges = agreement.Markup;
    journal.WillSearchContinue = (agreement.SearchAgain == 0) ? NoYes.No : NoYes.Yes;
    journal.IsGenericCurrencySearchEnabled = (agreement.GenericCurrency) ? NoYes.Yes : NoYes.No;
    journal.WillDeliveryDateControlDisregardLeadTime = (agreement.DisregardLeadTime) ? NoYes.Yes : NoYes.No;
    journal.AttributeBasedPricingId = agreement.PDSCalculationId;
}

response = context.SaveChanges(SaveChangesOptions.PostOnlySetProperties | SaveChangesOptions.BatchWithSingleChangeset);

I have tried the following, which is much quicker to create the collection but nothing is being sent to D365

var journalLst = new List();
foreach (var agreement in agreements)
{
    journal.DataAreaId = dataAreaId;
    journal.TradeAgreementJournalNumber = journalNumber;
    journal.LineNumber = index;
    journal.PriceApplicableFromDate = fromDate;
    journal.ToQuantity = agreement.QUANTITYAMOUNTTO;
    journal.Price = (decimal)agreement.CalculationAmount;
    journal.PriceApplicableToDate = toDate;
    journal.PriceCurrencyCode = agreement.CURRENCY;
    journal.ItemNumber = agreement.ITEMRELATION;
    journal.FromQuantity = agreement.QUANTITYAMOUNTFROM;
    journal.QuantityUnitSymbol = agreement.UNITID;
    journal.SalesPriceQuantity = agreement.PRICEUNIT;
    journal.SalesLeadTimeDays = agreement.DeliveryTime;
    journal.FixedPriceCharges = agreement.Markup;
    journal.WillSearchContinue = (agreement.SearchAgain == 0) ? NoYes.No : NoYes.Yes;
    journal.IsGenericCurrencySearchEnabled = (agreement.GenericCurrency) ? NoYes.Yes : NoYes.No;
    journal.WillDeliveryDateControlDisregardLeadTime = (agreement.DisregardLeadTime) ? NoYes.Yes : NoYes.No;
    journal.AttributeBasedPricingId = agreement.PDSCalculationId;
    journal.CustomerAccountNumber = (agreement.ACCOUNTCODE == (int)AccountCode.Table) ? agreement.ACCOUNTRELATION : null;
    journal.PriceCustomerGroupCode = (agreement.ACCOUNTCODE == (int)AccountCode.Group) ? agreement.ACCOUNTRELATION : null;

    journalLst.Add(journal);
}

DataServiceCollection journals = new DataServiceCollection(context);
journals.Load(journalLst);

response = context.SaveChanges();

Any ideas on how to send this data in a performant way would be much appreciated

I have the same question (0)
  • WillWU Profile Picture
    22,363 on at

    Hi richierich79,

    I think you should choose a more appropriate data integration strategy.

    docs.microsoft.com/.../integration-overview

    Have you considered using Batch Data APIs?

    docs.microsoft.com/.../recurring-integrations

  • André Arnaud de Calavon Profile Picture
    301,171 Super User 2025 Season 2 on at

    Hi richierich79,

    OData with F&O is not suitable for high performance scenarios. Check the links provided by Will.

  • richierich79 Profile Picture
    300 on at

    Thanks for your answers. It is somewhat frustrating as when I made the decision to use OData I had read docs that is supports 100,000 records

    I've had a look at the links and Batch Data APIs seems the way to go as all I need is a REST endpoint. Are these ready to go out of the box and do you know of any example projects like OData have?

    I did try and look for the Recurring job settings but couldn't find them on my instance. I still have 8.1, do I need to upgrade my D365 instance?

    In the mean time do you know of anyway to optimise the OData code I have?

  • WillWU Profile Picture
    22,363 on at

    Hi richierich79,

    Your code is fine, the main advantage of OData is that it is integrated synchronously. You shouldn't use it here.

    There is a data entity called "Trade agreement journal table", you could try to use it with DMF.

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    OData should not be used with high volumes, this doc describes some approaches for different integration scenarios: docs.microsoft.com/.../integration-overview

    There's no way to make it work fast with your volumes.

    Recurring data jobs have been supported since the very first version of D365FO.

    However I wonder why do you have 8.1 version?

    You can check Recurring Integrations Scheduler sample app if you need example code: github.com/.../Recurring-Integrations-Scheduler

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 467 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans