Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Answered

Architectural approach: T-SQL like logic in Dataverse

(0) ShareShare
ReportReport
Posted on by 17

Hi,

 

I have a client and we want to build a small/simple Order -> Delivery -> Invoice system for him.

Now we are used to work with MS SQL Server and MS Access to build those type of Apps but if we want to build this with:

 

- Dataverse

- Power Apps Model Driven 

 

Where would you write the logic to for example create a Delivery from an Order?

 

In SQL Server we would write a Stored Procedure with the OrderID as parameter to create a Delivery.

 

But in the Power Platform I can't see a place where to write that function.

 

I was also thinking to use Azure SQL and use virtual tables and still use a SP to execute that function.

 

But I was wondering if there was an performant option in Dataverse itself..

 

Thank you for the info!!

Categories:
  • LT-20081525-0 Profile Picture
    17 on at
    Re: Architectural approach: T-SQL like logic in Dataverse

    Hi,

     

    Thanks for the info!

    Here is also a good blogpost: https://www.pragmatic-development.io/blog/implement-business-logic-with-dataverse-custom-api/

  • Verified answer
    ChrisPiasecki Profile Picture
    6,389 Most Valuable Professional on at
    Re: Architectural approach: T-SQL like logic in Dataverse

    Hi @LaurentzT,

     

    If you're looking to encapsulate some specific business function/action that can be run on-demand or automatically, then a Custom Action or Custom API would be the way to go (which one you should choose depends on how you intend to invoke it). These can be invoked real-time via a Dataverse real-time workflow, JavaScript, Plugins, or some external integration. They can also be called asynchronously via Power Automate using the Dataverse connector.

     

    Note that you should not do heavy processing inside the platform and should be kept well under 2-minutes of execution. If you need to do more heavy processing or asynchronous processing that also needs to integrate with other systems, then you should move this processing out to Power Automate, Azure Logic Apps, or Azure Functions, or Azure Data Factory.

     

    ---
    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

  • Drew Poggemann Profile Picture
    9,278 Most Valuable Professional on at
    Re: Architectural approach: T-SQL like logic in Dataverse

    Hi @LaurentzT 

     

    I would assume you would want to look at Plugins here...  Adding @ChrisPiasecki to the conversation as he is a pro-dev and might have better thoughts...

  • LT-20081525-0 Profile Picture
    17 on at
    Re: Architectural approach: T-SQL like logic in Dataverse

    Hi,

     

    I'm have no problem with the database schema but more with the function that needs to be executed.

     

    For example (the real SP will have more logic and code) I have to write this function in Dataverse and call it from my ModelDriven App for the selected Order:

     

    usp_CreateDeliveryByOrderID (@intOrderID int)

    begin

     

    insert into Delivery (DeliveryNr, DeliveryDate, CustomerID)

    select fDeliveryNR(), getdate(), CustomerID from Order where OrderID= @intOrderID

     

    insert into Deliverylines (DeliveryID, ProductID, Quatity, Description)

    select @DeliveryID, ProductID, Quantity, Description from OrderLine where OrderID= @intOrderID

    end

     

    So how and where would I write that code in a pure Dataverse environment? 

    I think it would also be possible with a Power Automate Flow but that will be tomany steps and also slow...

     

    Thank you! 

     

  • Drew Poggemann Profile Picture
    9,278 Most Valuable Professional on at
    Re: Architectural approach: T-SQL like logic in Dataverse

    Hi @LaurentzT ,

    Dataverse contains native relationships you can setup (1:N, N:N) within the platform.  You could create an Order table and then Create the Delivery table with a Lookup column for the Order table.  This creates the relationship behind the scenes between the two tables and in the Model App you would be setting the Order Primary Name field on the Delivery.  In the model app you could create a tab or subgrid for Deliveries and then choose to add one and it will automatically set the Order on the Delivery and you could populate the additional details.

     

    Is this what you are trying to do?  A couple good links here:

    https://learn.microsoft.com/en-us/power-apps/maker/data-platform/create-edit-entity-relationships 

    https://learn.microsoft.com/en-us/training/paths/create-relationships-common-data-service/ 

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Microsoft Dataverse

#1
mmbr1606 Profile Picture

mmbr1606 22 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 17

#3
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

Overall leaderboard

Featured topics