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?
0
Answers
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:
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
My function is bigger than what you shown... in my sales header table.
My series group table don't have any information, so I used the SalesSetup information...
In this case I've changed to this ,
But in the page, it changed when I press new the series "MRPV1" to "MRVFA"
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:
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.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
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.
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.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!