Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How to split & insert transactions

Posted on by 572

Hi Experts,

I have a requirement that in my Table I have some data that needs to be splitted by date & hours. Can anyone help me by providing the best way to achieve this please. 

Consider the table - MyTable has fields From date, To date, From time, To Time & hours. 

Consider the record - From Date           To Date              From Time        To Time            Hours

                                   23/05/2021        25/05/2021           10:00 am         12:00 am             38

I need to split above record into two records 14 hours for 23/05/2021 & 24 hours for 24/05/2021. There are around 10,000 records to be splitted in this way, what will be the best way to get it done ? AOT job, Class or SQL. Can any one help with the best logic also please.

Thanks in advance. 

  

  • Verified answer
    Leo Chen Profile Picture
    Leo Chen on at
    RE: How to split & insert transactions

    I believe you need to create your own class. And  2 key methods would be 

    1. Validate if a record needs to be split according to given From Time. Take your data as example, you need to compare the Hours on the record with rest time of a day according to the From time. In our case the rest time of a day would be 24- 10= 14. Since 38 > 14, this record needs to be split. The return outcome would be True. Else return false. 

    2. if #1 method returns true, then split current record to 2 ones. Parameter would be from date and from time. For the generated 1st record, the new From date would be the parameter value which is May 23. The hours should be rest time of a day based on from time, which would be 14 hours. For the generated 2nd record, The From date would be parameter value +1 which would be May 24. The from time should be 12:00am. The Hours should be rest hours which would be 38- 14 = 24 hours. 

    Once above 2 methods are ready, you need to continue to validate if the generated second record needs to be split or not. If yes, then go to the second method to continue split this record. So as you can this is a recursive funtion. 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans