Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Routing

Posted on by Microsoft Employee

On the Routing page within the lines if there is a line and the user tries to change the status of the routing to certified while the Routing Link Code field is empty then it should error. 

How can I write this and where should it be written? 

As an example of what i mean in the image below if the user attempted to change this to certified it should error as there isn't a routing link code in one of the lines. 

60.PNG

*This post is locked for comments

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Routing

    Hello,

    Definitely it will fire.

    Do something.

    First check Routing Line table and Routing Header table,

    Check the link, which field is linked with Routing Header field,

    That field you have to filter,

    Write something like,

    recRoutingLines.SETRANGE("Document No.", "No.");

    Then beased on Header table lines are filterd,

    Here recRoitingLine is a record variable of Routing Line table.

    You wrote

    recRoutingLines.SETRANGE("No.", recRoitingLine."No.");

    So it get wrong data.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Routing

    Hi thanks again. I tried to run the code however the  recRoutingLines.SETRANGE(recRoutingLines."Document No.", "No."); was throwing an error so I changed it to as you can see in the image below. Regardless it's somehow still not firing the error :(

    62.PNG

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Routing

    Hello,

    Check this code.

    IF (Status <> xRec.Status) AND (Status = Status::Certified) THEN  BEGIN

      recRoutingLines.RESET;

      recRoutingLines.SETRANGE(recRoutingLines."Document No.", "No.");

      recRoutingLines.SETRANGE(recRoutingLines."Routing Link Code", '');

      IF recRoutingLines.FINDFIRST THEN

         recRoutingLines.FIELDERROR(recRoutingLines."Routing Link Code");

     CheckRouting.Calculate(Rec,'');

    END;

  • Suggested answer
    RE: Routing

    Hi,

    Check if this code works. Also, I have not considered other implications. Please add other filters/code if needed.

    IF Status <> Status::Certified THEN
    BEGIN
       recRoutingLines.RESET;

       recRoutingLines.SETRANGE(recRoutingLines."Document No.", "No.");
       recRoutingLines.SETRANGE(recRoutingLines."Routing Link Code", '');
       IF recRoutingLines.FIND('-') THEN
          ERROR('Your error message!');
    END;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Routing

    Hi I tried adding a quick soloution into where you suggested however it hasn't seemed to of worked. How can I rewrite this to work properly. Currently it doesn't appear to recognize it at all.  

    Thanks

    61.PNG

  • Suggested answer
    RE: Routing

    Hi,

    Then you have to take the code away from OnModify() and put it to OnValidate() trigger of the needed fields. Please adjust the code as per your requirements.

    Hope it helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Routing

    Thanks however after trying this code I don't want it to throw an error once the status is changed to  Certified and the routing link code is empty. This throws errors when ever anything on the page is changed such as changing the status back to Under Developed from Certified. How can I adjust this?

  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Routing

    Hello,

    Also Check Table Routing Header [99000763] in

    Status - OnValidate Trigger

    Some code will execute,  analysed that code, you will get Idea.

  • Suggested answer
    RE: Routing

    Hi,

    On BOM Routing Header table, OnModify() Trigger,

    RoutingLines.SETRANGE("Document No.", "No.");

    IF RoutingLines.FIND('-') THEN

      ERROR('Routing Lines Exist');

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans