Options

How to rollback if the import is failed?

julkifli33julkifli33 Member Posts: 1,073
hi all , i create i report to import to sales header and sales line (1 file inserted to these 2 tables)
my code is first insert into sales header off course
and then i inserted to sales line... using Sales Header."No." become Sales Line."Document No."
but sometimes if i want to add Sales Line, it got an error because we haven't input the item
but it still create the header....
if we import once again, it will create sales header and sales line, which is will be redundant
so... what should i do, to prevent it create sales header before it check that sales line is correct
thanks

Comments

  • Options
    hemantOnehemantOne Member Posts: 98
    Hi,

    Temporary table may be useful.
    I think first insert in temporary table of Sales Header and line .If no error after all records passed then insert temporary into real tables.
    Regards,
    Hemant
    They can conquer who believe they can
    .
  • Options
    raveendran.sraveendran.s Member Posts: 119
    I suggest to use RIM tool here. This will give us the list of errors at the time of importing
    --
    Regards,
    Raveendran.BS
  • Options
    kinekine Member Posts: 12,562
    1) There must be some COMMIT in the process. Just use the client monitor to find it.
    2) The commit is not in standard I assume. It seems like bad concept.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    rmv_RUrmv_RU Member Posts: 119
    kine wrote:
    1) There must be some COMMIT in the process. Just use the client monitor to find it.
    2) The commit is not in standard I assume. It seems like bad concept.
    In additional, you can protect code from the unexpected commit by adding SalesHeader.consistent(false) before the import routline and SalesHeader.consistent(true) after
    Looking for part-time work.
    Nav, T-SQL.
  • Options
    ara3nara3n Member Posts: 9,255
    That's a good trick. =D>
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    reijermolenaarreijermolenaar Member Posts: 256
    Applause indeed!! =D>

    This will save me a lot of time the next time I have to search for a commit.
    Reijer Molenaar
    Object Manager
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    rmv_RU wrote:
    kine wrote:
    1) There must be some COMMIT in the process. Just use the client monitor to find it.
    2) The commit is not in standard I assume. It seems like bad concept.
    In additional, you can protect code from the unexpected commit by adding SalesHeader.consistent(false) before the import routline and SalesHeader.consistent(true) after

    =D>

    WOW that is brilliant.

    It makes you think two things. First, D'oh why didn't I think of that. And Second, isn't it great that after all these years in Navision I can still learn something new.
    David Singleton
Sign In or Register to comment.