Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Record Insertion

(0) ShareShare
ReportReport
Posted on by

issue.png

I am getting an error when inserting records, maybe i am missing something and need a second set of eyes.

LNO is a integer field, auto increment, Document No. is  code field,

here is my code

ConvertMptToJcs(DocNo : Code[20])
//imports date into jcs lines
MptLine.SETRANGE("Document No.", DocNo);
MptLine.SETFILTER(Qty, '>0');
IF MptLine.FINDSET THEN BEGIN
  REPEAT
    JcsLine.SETRANGE(JcsLine."Document No.", DocNo);
    IF NOT JcsLine.FINDSET THEN BEGIN //check to see if jcs lines exist, if not, create
      JcsLine.INIT;
      JcsLine."Document No." := DocNo;
      JcsLine.Type := JcsLine.Type::Item;
      JcsLine."No." := MptLine."Part No.";
      JcsLine.Description := MptLine.Description;
      JcsLine.INSERT;
    END ELSE
    IF JcsLine.FINDSET THEN BEGIN //check to see if jcs lines exist, if so then add new line
      JcsLine.INIT;        
      JcsLine."Document No." := DocNo;
      JcsLine.Type := JcsLine.Type::Item;
      JcsLine."No." := MptLine."Part No.";
      JcsLine.Description := MptLine.Description;
      JcsLine.INSERT;
    END;
  UNTIL MptLine.NEXT = 0;
END;

*This post is locked for comments

  • bharathkarunakaran Profile Picture
    bharathkarunakaran 475 on at
    RE: Record Insertion

    Hi  Hahjoel,

    I think that line has already exists.Just go that table where the lines are created and delete that  line and then try to run your code.

    Regards,

    Bharath K

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans