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, ...
Unanswered

odata action vs custom service

(1) ShareShare
ReportReport
Posted on by
Hi,

I would like to know what are the advantages and disadvantages of using custom service vs odata action.
For example:
1. Is there a difference in performance?
2. would odata action require power platform to be enabled? or anything? or are there any restrictions of using it?
3. what are the advantages and disadvantages of using each one
4. when should i decide to use odata action and when should i decide to use custom service OR when should i decide to not use one of them?

I have this odataAction already implemented:
[SysODataActionAttribute('Test', true)]    
public void test(Reference _ref)    
{       
    Table1 table1  = Table1::find(this.Id, true);  
    Class1 class1 = Class1::newFromReference(table1, _ref);   
    class1.runOperation();  
}
and if i will create the custom service, it will contain the same code, where the request contract will contain /ref/ and /Id/

what this runOperation does is that it updates two tables with some logic

this odataAction or custom service, will be called by the middle ware, and it will be called alot during the day

5. So what would you advice in this case?

I already read this useful article, but i would like to hear your thoughts
https://markedcode.com/index.php/2022/11/18/d365-x-odata-actions/
I have the same question (0)
  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at
    1. I don't know exactly, but if there is a difference, I would expect it very small.
    2. Not at all. OData services where there long time before Power Platform.
    3+5. One think I can think of is that OData are included in virtual entities, therefore you can use them in Dataverse (e.g. the Dataverse connector in PowerApps). And there are benefits coming from the fact that OData is a standard, therefore you can utilize the metadata, the tools capable of working with OData etc. And obviously, if your action is related to a particular data entity, it's good to have the action directly in the entity. But if you have code not related to any entity, a custom service (or a special entity just for that) may make a better sense.
    4. If you create a custom service, you need to add id as a parameter.
  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at
    I'm sorry, but it's not clear what you want from me. You're "what are the disadvantages with going with the odata action or if i should create a custom service"' but we already talked about it. Don't you have a more specific question?
  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at
    Hi,
     
    I will add my two cents here. With a service, you provide several methods as an interface for a specific functionality. E.g. Microsoft created a timesheet service where methods are provided to read timesheets to present data, add or maintain timesheets, and submit timesheets. Next to interaction with the timesheet tables, it also has methods to provide data for lookup fields such as activities and categories. In this case, the service provides interfaces for a full feature.
     
    Using OData actions, you would only start an action to be executed in Dynamics 365. It is related to one entity/table. You mentioned you have a table and based on that table an entity. A data entity is required for using OData operations. 
    Having a base key to find a record and then start updating this table and related tables is OK for an OData action.
     
    In your scenario, you can use both. It would depend on using other data entities for integrations. Then the OData action would give more consistency in the usage of integration options. Of course, you might have a personal preference as well.
     

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
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans