Skip to main content

Notifications

Announcements

No record found.

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

Can't delete data from SalesInvoiceHeaderFooterTmp table

(0) ShareShare
ReportReport
Posted on by 30
Hi Experts,
 
I am trying to create a batch job to clean temp data in sales invoice header footer temp and sales invoice tmp tables. The data is deleting from sales invoice tmp successfully but data still resides when deleting data from sales invoice header footer temp. I don't know what is wrong I am doing. Also I see there is created transaction ID property enable in sales invoice header footer temp table. Please guide me.
 
SalesInvoiceHeaderFooterTmp headerTemp;
SalesInvoiceTmp             lineTemp;
DataArea                    company;
while select id from company
where company.id != /DAT/
 {
   changecompany(company.id)
     {
        ttsbegin;
        delete_from headerTemp;
        ttscommit;
        ttsbegin;
        delete_from lineTemp;
        ttscommit;
      }
 } 
  • Can't delete data from SalesInvoiceHeaderFooterTmp table
    Hi,
     
    search AOT to find SalesInvoiceTempDataCleanup classes and MI.
     
    /// <summary>
    /// The <c>SalesInvoiceTempDataCleanup</c> class evaluates and deletes
    /// temporary records in <c>SalesInvoiceTmp</c> and other associated tables.
    /// </summary>
    internal final class SalesInvoiceTempDataCleanup
    {
        /// <summary>
        /// Removes records.
        /// </summary>
        internal void deleteRecords()
        {
            ttsbegin;
            SalesInvoiceTmp salesInvoiceTmp;
            delete_from salesInvoiceTmp; // Not a per-company table; crosscompany is not needed here
     
            SalesInvoiceTmp_IN salesInvoiceTmp_IN;
            salesInvoiceTmp_IN.skipDatabaseLog(true);
            salesInvoiceTmp_IN.skipEvents(true);
            delete_from crosscompany salesInvoiceTmp_IN;
     
            SalesInvoiceHeaderFooterTmp headerFooterTmp;
            headerFooterTmp.skipDatabaseLog(true);
            headerFooterTmp.skipEvents(true);
            delete_from crosscompany headerFooterTmp;
     
            SalesInvoiceLocalizationTmp localizationTmp;
            localizationTmp.skipDatabaseLog(true);
            localizationTmp.skipEvents(true);
            delete_from crosscompany localizationTmp;
     
            SalesInvoicePaymentStubTmp paymentStubTmp;
            paymentStubTmp.skipDatabaseLog(true);
            paymentStubTmp.skipEvents(true);
            delete_from crosscompany paymentStubTmp;
            ttscommit;
        }
     
     
    BR!
  • Martin Dráb Profile Picture
    Martin Dráb 230,468 Most Valuable Professional on at
    Can't delete data from SalesInvoiceHeaderFooterTmp table
    What did you find when you investigated the data? Are the records for the partition where you ran your code and aren't there in DAT company? Weren't they created after the deletion?
     
    By the way, you code is dangerous because it can delete data of currently running reports. Be careful where and when you use it.
     
    The fact that Created Transaction Id property is enabled is correct. It's needed when pre-processing is used with regular (persistent) tables.

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,759 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans