Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

How to use a unique Line No. when inserting a line

(0) ShareShare
ReportReport
Posted on by 262
Hello! I have made a codeunit that lets me insert a line into the Output Journal using the Item Journal Line record.
I have managed to insert the values I want and validate them successfully, inserting one line into the table.
 
However, I am struggling to insert more than one line without deleting the first one. The reason for this is that I get this error: 
/The record in table Item Journal Line already exists. Identification fields and values: Journal Template Name='AVGANG',Journal Batch Name='STANDARD',Line No.='0'  CorrelationId:  fcde2248-cbd5-41b3-9655-e10a926ebed8./
 
I understand that the Line No. needs to change, but I am fairly new to AL, and don't quite understand how I can get the next available Line No.
AI keeps suggesting that I use the function NextLineNo(), but this function is not defined in my record /Item Journal Line/.
 
How can I get the next available Line No every time I insert a line?
  • Sayli Mandavkar Profile Picture
    3 on at
    How to use a unique Line No. when inserting a line
    You have to set these properties on the page
     

    AutoSplitKey = true;

    MultipleNewLines = true;

     

    Hope this helps

  • Suggested answer
    YUN ZHU Profile Picture
    78,675 Super User 2025 Season 1 on at
    How to use a unique Line No. when inserting a line
    The line number of Item Journal Line is achieved through the AutoSplitKey Property.
     
    You need to find the last one used (Findlast) and then plus 10000.
     
    Hope this helps.
    Thanks
    ZHU

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,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans