web
You’re offline. This is a read only version of the page.
close
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

check for existing job numbers and increment them if they exist

(1) ShareShare
ReportReport
Posted on by 48
When it enters the loop it should check if a job number already exists or not if exists it should increment like 001 to 002

for example Sell-to Customer No = 1000
job number will be1000-001
if 1000-001 exist the it should increment to 1000-002

code:
trigger OnAfterValidate()
            var
                GetNo: Text;
            begin
                GetNo := '';
                Rec.get(rec./No./);
                if Rec.FindSet() then
                    repeat
                        GetNo := Rec./Sell-to Customer No./ + '-' + IncStr('001');
                        Rec./No./ := GetNo;
                        Rec.Rename(GetNo);
                    until Rec.Next() = 0;
            end;
I have the same question (0)
  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at
    Hi,
     
    I am not sure what you are trying to do but
     
    To put it simply once you get new number generated - Just verify using If not .GET() then assign value otherwise keep repeating.
     
    Regards,
    Saurav Dhyani
  • Suggested answer
    YUN ZHU Profile Picture
    95,761 Super User 2025 Season 2 on at
    It sounds like you can do it with the standard No. Series feature. For example, you can define a No. Series for each customer. When creating a job, the system can automatically pick up the number.
     
    More details:
    Dynamics 365 Business Central: No. Series Relationships (Multiple Number Series)
    Dynamics 365 Business Central: New “No. Series” module
     
     
    Hope this helps.
    Thanks.
    ZHU
     
  • Suggested answer
    JM Profile Picture
    49 on at
    Hi there!
     
    As Yhun Zhu has commented, if you are trying to increment No. Series for documents you need to use the standard feature.
     
    However for the sake of resolution, basing on your code, here is my suggestion. The following code checks if a job number already exists for a customer and increments the suffix accordingly:
     
     
     
    A more 'elegant' solution would be in any case to generate those auto incremental job numbers utilizing the existing Business Central No. Series functionality (No. Series Management Codeunit), which is realiable and well-integrated.
     
    Hope it helps! 
     
    BR,
    JM
     
  • Suggested answer
    Ben Baxter Profile Picture
    6,620 Super User 2025 Season 2 on at
    I would argue the case you do not need your Customer Number included in your Project/Job No.
     
    On the Project you select the Customer of that Project.  From the Customer you can look up their Projects.  From the Project list you can Search (or Filter) for your Customer No., and it will show all Projects for that Customer.
     
    There is really no need to include the Customer No. in the Project No.  This could be an example of developing something from the old system that didn't have the features/capabilities Business Central does for linking Customers and Projects.
     
    Best Regards,
    Ben Baxter
    Accent Software Inc

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,126

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 744 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 674 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans