Rename

pvarpvar Member Posts: 157
edited 2008-04-16 in Navision Attain
Is there a way to bypass the OnRename trigger of the table while renaming the primary key of a table from a report?

I know for INSERT (also for MODIFY & DELETE) you could specifiy INSERT(FALSE) to bypass the table trigger but I couldn't find anything like that for RENAME.

Thanks for any help.

Comments

  • kinekine Member Posts: 12,562
    No, there is no standard way for that.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,115
    You can put the code in the rename-trigger in a function and call it from the rename-trigger.
    Function OnRenameTrigger
    IF NOT blnSkipRenameCode THEN BEGIN
    
    .. the standard rename code
    
    
    END;
    

    Create also the function:
    Function SkipRenameCode(IblnSkipRenameCode as Boolean)
    blnSkipRenameCode := IblnSkipRenameCode;
    

    Now, just before you run the RENAME, do this:
    recSomeRecord.SkipRenameCode(TRUE);
    recSomeRecord.RENAME(new primary key-values);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • pvarpvar Member Posts: 157
    Thanks for the suggestion. I knew I could do something like that but I was trying to see if I could rename without having to change the table trigger.
  • ottobeottobe Member Posts: 67
    I am using a boolean to bypass the code as described here, and that works fine in the native verson of a 3.70 database.
    However when running on SQL server the system runs the rename trigger a second time - and that time it is out of the context so the boolean bypass do not work.
    Is this correct, and is there a way to overrule this?
  • TomasTomas Member Posts: 420
    What about going in this way:
    - creating temp variable and copying data into it
    - change (rename) fields you want to rename
    - delete old item with delete(false)
    - insert new item from temp variable with insert(false)

    In this way, you will change (rename) the fields you want, and will not triger any of OnRename, OnInsert, OnDelete trigers.
  • kinekine Member Posts: 12,562
    Tomas wrote:
    What about going in this way:
    - creating temp variable and copying data into it
    - change (rename) fields you want to rename
    - delete old item with delete(false)
    - insert new item from temp variable with insert(false)

    In this way, you will change (rename) the fields you want, and will not triger any of OnRename, OnInsert, OnDelete trigers.

    Yes, but it means that related fields will not be renamed too...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • tinoruijstinoruijs Member Posts: 1,226
    I would advice to just use the rename like it was meant to be.

    If you want to speed up the proces of renaming, I think the fastest way is to clean up the database. Take a look at the connected tables and see in which tables you could delete some records.. :wink:

    Tino Ruijs
    Microsoft Dynamics NAV specialist
Sign In or Register to comment.