Skip to main content

Notifications

Announcements

No record found.

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/
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,735 Super User 2024 Season 2 on at
    odata action vs custom service
    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.
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,466 Most Valuable Professional on at
    odata action vs custom service
    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?
  • Martin Dráb Profile Picture
    Martin Dráb 230,466 Most Valuable Professional on at
    odata action vs custom service
    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.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans