Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Suggested answer

Modify Data from Source table to destination table after inserting

Posted on by 25

I created Source table and destination table . 

1. Inserted records from source to destination using insert in codeunit 

2.Now I changed Records in source Table I want to update the same using codeunit help me

I am getting this error:

The Insert Modify Task destination already exists. Identification fields and values: No.='101'
---------------------------
OK
---------------------------

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,933 Super User 2024 Season 2 on at
    RE: Modify Data from Source table to destination table after inserting

    Hi, It seems that the record already exists when you insert it again, please check before insert.
    for example

    if destination.get(PrimaryKey) then
     exit;

    Hope this will help.

    Thanks.

    ZHU

  • RE: Modify Data from Source table to destination table after inserting

    Hello,

    You can either empty the destination table every time (DELETEALL;), and then re-insert every record from the source table. If you only want to update existing records in the destination table, then TRANSFERFIELDS and MODIFY should do it, like this, assuming that source and destination table definitions are identical:

    DestinationTable.GET(SourceTable.PrimaryKey);

    DestinationTable.TRANSFERFIELDS(SourceTable);

    DestinationTable.MODIFY;

    I hope you can use that?

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans