Sales Order header force series no

catiamatos1991
Member Posts: 158
Hi everyone, I'm having a little trouble trying to assign different series no according to the user logged in the NAV system to create a new sales order.
So my page Sales order have the "Sales header" table as source table and if i try to create a new record I want to have in the "posting no. series" the user posting no.
if I do this in the "OnNewRecord" trigger when I enter the page everything is ok but when i change anything it changes automatically to another series no.
So after a little debugging I found this piece of code in a "InitRecord" function in sales header table, so it's explained why I can't change in my page just the "posting no".
InitRecord()
SalesSetup.GET;
CASE "Document Type" OF
"Document Type"::Quote,"Document Type"::Order:
BEGIN
//soft,sn
IF InSeriesGroup(1) THEN
NoSeriesMgt.SetDefaultSeries("Posting No. Series",SeriesGroups."Posted Invoice")
ELSE BEGIN
//soft,en
User.GET(USERSECURITYID);
NoSeriesMgt.SetDefaultSeries("Posting No. Series",User."Posting No."); //returns MRVF1 (what i want)
//NoSeriesMgt.SetDefaultSeries("Posting No. Series",SalesSetup."Posted Invoice Nos."); // returns MRVFA
//soft,sn
END;
The problem is when I change the code
NoSeriesMgt.SetDefaultSeries("Posting No. Series",SeriesGroups."Posted Invoice") to
User.GET(USERSECURITYID);
NoSeriesMgt.SetDefaultSeries("Posting No. Series",User."Posting No.");
in my page I got the error that the series code "MRVF1" doens't exist.. and its not true.. in my user I have assign to my user this series on Posting no field, and in the series table is defined also as in the series line table.
What am I missing?
So my page Sales order have the "Sales header" table as source table and if i try to create a new record I want to have in the "posting no. series" the user posting no.
if I do this in the "OnNewRecord" trigger when I enter the page everything is ok but when i change anything it changes automatically to another series no.
So after a little debugging I found this piece of code in a "InitRecord" function in sales header table, so it's explained why I can't change in my page just the "posting no".
InitRecord()
SalesSetup.GET;
CASE "Document Type" OF
"Document Type"::Quote,"Document Type"::Order:
BEGIN
//soft,sn
IF InSeriesGroup(1) THEN
NoSeriesMgt.SetDefaultSeries("Posting No. Series",SeriesGroups."Posted Invoice")
ELSE BEGIN
//soft,en
User.GET(USERSECURITYID);
NoSeriesMgt.SetDefaultSeries("Posting No. Series",User."Posting No."); //returns MRVF1 (what i want)
//NoSeriesMgt.SetDefaultSeries("Posting No. Series",SalesSetup."Posted Invoice Nos."); // returns MRVFA
//soft,sn
END;
The problem is when I change the code
NoSeriesMgt.SetDefaultSeries("Posting No. Series",SeriesGroups."Posted Invoice") to
User.GET(USERSECURITYID);
NoSeriesMgt.SetDefaultSeries("Posting No. Series",User."Posting No.");
in my page I got the error that the series code "MRVF1" doens't exist.. and its not true.. in my user I have assign to my user this series on Posting no field, and in the series table is defined also as in the series line table.
What am I missing?
0
Answers
-
If you look into T36 Sales Header the code selecting appropriate number serie is already there. If you look closer there is a function which selects no series depending on document type:
It is pretty simple in standard NAV, and it should be relatively easy to modify it to return in specific circumstances the numer series you want:
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
So my suggestion is to change the "Invoice" Document type and put
My function is bigger than what you shown... in my sales header table.LOCAL GetNoSeriesCode() : Code[10] //soft,sn IF "Series Group" <> '' THEN IF SeriesGroups.GET("Series Group") THEN CASE "Document Type" OF "Document Type"::Quote: IF SeriesGroups.Quote <> '' THEN EXIT(SeriesGroups.Quote); "Document Type"::Order: IF SeriesGroups.Order <> '' THEN EXIT(SeriesGroups.Order); [b] "Document Type"::Invoice: BEGIN IF "Debit Memo" THEN BEGIN IF SeriesGroups."Debit Memo" <> '' THEN EXIT(SeriesGroups."Debit Memo"); END ELSE IF SeriesGroups.Invoice <> '' THEN EXIT(SeriesGroups.Invoice); END;[/b] "Document Type"::"Return Order": IF SeriesGroups.Return <> '' THEN EXIT(SeriesGroups.Return); "Document Type"::"Credit Memo": IF SeriesGroups."Credit Memo" <> '' THEN EXIT(SeriesGroups."Credit Memo"); "Document Type"::"Blanket Order": IF SeriesGroups."Blanket Order" <> '' THEN EXIT(SeriesGroups."Blanket Order"); END; IF UserSetup.GET(USERID) THEN IF UserSetup."Sales Series Group" <> '' THEN BEGIN SeriesGroups.GET(UserSetup."Sales Series Group"); CASE "Document Type" OF "Document Type"::Quote: IF SeriesGroups.Quote <> '' THEN EXIT(SeriesGroups.Quote); "Document Type"::Order: IF SeriesGroups.Order <> '' THEN EXIT(SeriesGroups.Order); [b]"Document Type"::Invoice:[/b] BEGIN IF "Debit Memo" THEN BEGIN IF SeriesGroups."Debit Memo" <> '' THEN EXIT(SeriesGroups."Debit Memo"); END ELSE [b] IF SeriesGroups.Invoice <> '' THEN EXIT(SeriesGroups.Invoice);[/b] END; "Document Type"::"Return Order": IF SeriesGroups.Return <> '' THEN EXIT(SeriesGroups.Return); "Document Type"::"Credit Memo": IF SeriesGroups."Credit Memo" <> '' THEN EXIT(SeriesGroups."Credit Memo"); "Document Type"::"Blanket Order": IF SeriesGroups."Blanket Order" <> '' THEN EXIT(SeriesGroups."Blanket Order"); END; END; //soft,en [b]CASE "Document Type" OF[/b] "Document Type"::Quote: EXIT(SalesSetup."Quote Nos."); "Document Type"::Order: EXIT(SalesSetup."Order Nos."); [b] "Document Type"::Invoice:[/b] //soft,sn BEGIN IF "Debit Memo" THEN EXIT(SalesSetup."Debit Memo Nos.") ELSE //soft,en [b] EXIT(SalesSetup."Invoice Nos.");[/b] END; //soft,n "Document Type"::"Return Order": EXIT(SalesSetup."Return Order Nos."); "Document Type"::"Credit Memo": EXIT(SalesSetup."Credit Memo Nos."); "Document Type"::"Blanket Order": EXIT(SalesSetup."Blanket Order Nos."); END;
My series group table don't have any information, so I used the SalesSetup information...
In this case I've changed to this ,"Document Type"::Invoice: BEGIN IF "Debit Memo" THEN EXIT(SalesSetup."Debit Memo Nos.") ELSE BEGIN User.GET(USERSECURITYID); Exit(User."Posting No."); END; END;
But in the page, it changed when I press new the series "MRPV1" to "MRVFA"0 -
Would you please next time use code quotation
It really makes the code much more readable.
I'd suggest to get all the custom code out to a separte function (or functions) and modify the GetNoSeriesCode() it much simple way:
This will allow you to test your own code and check the output (the number series) before it is passed to other functions:
Then the first thing to try would be just this:LOCAL GetMySeriesCode() : Code[10] EXIT('MRVF1'); //or whatever series seems to be poblematic
Later I would rebuild your logic based on "Series Group" and other fields inside GetMySeriesCode() bit by bit, testing every change by means of checking value returned in GetNoSeriesCode() to ensure result is expected and correct.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
After a little debug I found that If I use this lines of code in the end of my InitRecord function I have everything fine.. each user have the right series no. Although the problem is in the Sales Credit Memo, the posting no series field appears with the wrong series number, and I cant' figure a way to force it in the page "Sales Credit Memo", because the sales header table overwrites the posting no... this is what I thought
IF "Document Type" = "Document Type"::"Order" THEN BEGIN User.GET(USERSECURITYID); "Posting No. Series" := User."Posting No."; END;
And with this little piece of code the series is right in both pages. The code of series in table Sales header remain the same.0 -
After a little debug I found that If I use this lines of code in the end of my InitRecord function I have everything fine.. each user have the right series no. Although the problem is in the Sales Credit Memo, the posting no series field appears with the wrong series number, and I cant' figure a way to force it in the page "Sales Credit Memo", because the sales header table overwrites the posting no... this is what I thought
IF "Document Type" = "Document Type"::"Order" THEN BEGIN User.GET(USERSECURITYID); "Posting No. Series" := User."Posting No."; END;
And with this little piece of code the series is right in both pages. The code of series in table Sales header remain the same.0 -
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions