Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Item Id duplication

Posted on by Microsoft Employee

Hi friends,

I want to avoid the item id duplication in sales line using CAL code please give any solution.

thanks&Regards,

Ashwini. E

*This post is locked for comments

  • RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: Item Id duplication

    I will  support Alexander's answer that you should not completely avoid this because there might be a chances that you are making a Sales Order for the same item but with different Variants.

  • Verified answer
    Zaid Tariq Profile Picture
    Zaid Tariq 2,266 on at
    RE: Item Id duplication

    Hi,
    Use the logic as follow:

    CLEAR(SalesLine);
    
    SalesLine.SETCURRENTKEY("Document Type","Document No.",Type,"No.");
    
    SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
    
    SalesLine.SETRANGE("Document No.",SalesHeader."No.");
    
    SalesLine.SETRANGE(Type,SalesLine.Type::Item);
    
    SalesLine.SETRANGE("No.",Rec."No.");
    
    IF NOT SalesLine.ISEMPTY THEN
    
       ERROR('The item no. %1 is already exist',Rec."No.");


  • Suggested answer
    ManishS Profile Picture
    ManishS 6,578 on at
    RE: Item Id duplication

    Agree with Alexander Ermakov , rather than error show a message which indicates that the item is already been selected.

  • Suggested answer
    CDsilva Profile Picture
    CDsilva 4,184 on at
    RE: Item Id duplication

    Hi,

    In the OnValidate trigger for No, use SETRANGE

    SalesLine.SETRANGE(No.,No.);

    IF SalesLine.FINDFIRST THEN

    ERROR('The item no. is already used');

  • Verified answer
    Alexander Ermakov Profile Picture
    Alexander Ermakov 28,094 on at
    RE: Item Id duplication

    I would suggest not to restrict that completely but rather give user a notification so user can decide himself. There might be business cases when two lines with the same item are needed in the sales order.

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans