How to insert a new record in a table after the last record

dynamicshadynamicsha Member Posts: 20
How to insert a new record in a table after the last record at run time in microsoft nav through code and transfer the all the fileds of the existing record to the new inserted fields

Comments

  • euekimeuekim Member Posts: 21
    can you explain further??
    Thinking, programming, coding, developing == Music!
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • rmpatel22rmpatel22 Member Posts: 80
    If you want to generate Autonumber for new record, you can use No. Series or get last record and increase number by INCSTR function. To copy data from other record you can use TRANSFERFILEDS function.

    Yes, euekim is right, If you explain your requirement in details members can help you easily.
    Rakesh Patel
    Navision Developer
  • dynamicshadynamicsha Member Posts: 20
    If you want to generate Autonumber for new record, you can use No. Series or get last record and increase number by INCSTR function. To copy data from other record you can use TRANSFERFILEDS function.

    Yes, euekim is right, If you explain your requirement in details members can help you easily.
  • dynamicshadynamicsha Member Posts: 20
    I have a table GL Entry.. it has a field Tax amount. This tax amount field is zero for some record and noon zero for some.. i have to insert a new record if i found a tax amount field non zero and transfer its content to new record dat is added in last
  • rmpatel22rmpatel22 Member Posts: 80
    Its not advisable to enter records in G/L entry table by customized code, but if its necessory, you can do like this,

    GLEntry.RESET;
    IF GLEntry.FIND('+') THEN BEGIN
    GLEntryNew.INIT;
    GLEntryNew."Entry No." := GLEntry."Entry No.";
    GLEntryNew.TRANSFERFIELDS(GLEntry,FALSE);
    //You can change some field values here, if you want
    IF NOT GLEntryNew.INSERT THEN
    ERROR('Error Message');
    END;
    Rakesh Patel
    Navision Developer
  • dynamicshadynamicsha Member Posts: 20
    thank rakesh.. :D
  • David_SingletonDavid_Singleton Member Posts: 5,479
    dynamicsha wrote:
    I have a table GL Entry.. it has a field Tax amount. This tax amount field is zero for some record and noon zero for some.. i have to insert a new record if i found a tax amount field non zero and transfer its content to new record dat is added in last


    [-X [-X [-X [-X [-X [-X [-X [-X [-X

    ABSOLUTELY DO NOT DO THIS.
    David Singleton
  • bstoyanobstoyano Member Posts: 134
    If you need to make any corrections in the GL accounts, you can use your procedure to generate lines in the General Journal, which afterwards to post. I think this is a better approach.

    Further on, I would ask you what is the "non-technical" part of your requirement, why you want to interfere into the GL entries? If it is for correcting a wrong posting, then I strongly advice you to do it through a General Journal.
    Boris
    *
    Please, do not frighten the ostrich,
    the floor is concrete.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    rmpatel22 wrote:
    Its not advisable to enter records in G/L entry table by customized code, but if its necessory, you can do like this,

    GLEntry.RESET;
    IF GLEntry.FIND('+') THEN BEGIN
    GLEntryNew.INIT;
    GLEntryNew."Entry No." := GLEntry."Entry No.";
    GLEntryNew.TRANSFERFIELDS(GLEntry,FALSE);
    //You can change some field values here, if you want
    IF NOT GLEntryNew.INSERT THEN
    ERROR('Error Message');
    END;

    This must be the worst advise ever. ](*,) ](*,) ](*,) ](*,) ](*,)
    David Singleton
  • DenSterDenSter Member Posts: 8,305
    This must be the worst advise ever. ](*,) ](*,) ](*,) ](*,) ](*,)
    Really? I thought it was cool to randomly create copies of G/L Entry records :mrgreen:
  • rmpatel22rmpatel22 Member Posts: 80
    Hi David Singleton, I agree that my advise is wrong thats why in beginning I mentioned "Its not advisable to enter records in G/L entry table by customized code, but if its necessory"

    dynamicsha, don't do it as per my advise, All experts also telling not to add record G/L Entry table by this way.
    Rakesh Patel
    Navision Developer
  • David_SingletonDavid_Singleton Member Posts: 5,479
    rmpatel22 wrote:
    Hi David Singleton, I agree that my advise is wrong thats why in beginning I mentioned "Its not advisable to enter records in G/L entry table by customized code, but if its necessory"

    dynamicsha, don't do it as per my advise, All experts also telling not to add record G/L Entry table by this way.


    if someone asks you how to set their head on fire, the correct advise is to tell them NOT to set their head on fire, you don't suggest it as a bad idea and then show them how to do it*.

    * OH wait I did that didn't I :mrgreen:
    David Singleton
  • SLF25SLF25 Member Posts: 37
    Really? I thought it was cool to randomly create copies of G/L Entry records

    There is nothing random with this code, it will always error out, so it is mostly harmless \:D/
  • David_SingletonDavid_Singleton Member Posts: 5,479
    SLF25 wrote:
    Really? I thought it was cool to randomly create copies of G/L Entry records

    There is nothing random with this code, it will always error out, so it is mostly harmless \:D/

    Well spotted, I didn't even read it in detail. But yes the ERROR('Error Message") will pop up every time.
    David Singleton
  • KowaKowa Member Posts: 923
    SLF25 wrote:
    There is nothing random with this code, it will always error out, so it is mostly harmless \:D/
    Yes , but with a slight alteration it could be quite harmful. There are NSC's where you will get fired instantly for code like this that writes directly to a ledger table without using the proper posting routine. [-X
    Kai Kowalewski
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Kowa wrote:
    There are NSC's where you will get fired instantly for code like this that writes directly to a ledger table without using the proper posting routine. [-X

    In Germany maybe :mrgreen: in some other countries maybe not.
    David Singleton
Sign In or Register to comment.