Get Document No from salesheader

jaro84
Member Posts: 17
Hi!
Im trying to get the Document No from current SalesOrder and store it in a variable, but it does not work..
Code is:
DocNo := SalesHeader."No.";
Document No is not stored in DocNo.
What is wrong?
Im trying to get the Document No from current SalesOrder and store it in a variable, but it does not work..
Code is:
DocNo := SalesHeader."No.";
Document No is not stored in DocNo.
What is wrong?
0
Comments
-
at which place are you trying?0
-
Im in form46(Sales Order Subform).. I want to insert a salesline and in order to do that, I have to know the SalesLine Document No.. It works fine if I hardcode DocNo0
-
There are somany triggers and functions..so in which trigger and function?
Why do you want to insert it and also in form level code?0 -
Form - OnInsertRecord(BelowxRec : Boolean) : Boolean
Thats where im inserting the line..
SalesLine."Document Type" :=1;
SalesLine."Document No." := '1033';
SalesLine."Line No." := 20000;
SalesLine.Type := 2;
SalesLine."No." := '1';
As you see, I have hardcoded the Document No., it works fine.. But I instead of hardcoding, I want to get the Document No dynamically0 -
jaro84 wrote:Form - OnInsertRecord(BelowxRec : Boolean) : Boolean
Thats where im inserting the line..
SalesLine."Document Type" :=1;
SalesLine."Document No." := '1033';
SalesLine."Line No." := 20000;
SalesLine.Type := 2;
SalesLine."No." := '1';
As you see, I have hardcoded the Document No., it works fine.. But I instead of hardcoding, I want to get the Document No dynamically
Why do you want to do this?
As soon as you enter No. field in Subform..all the common fields will be inserted automatically..0 -
Because Im forced to..
its not enough to just enter the No. field.. If it was enough then there wasnt a problem.
If you cant answer the question, then stop replying0 -
jaro84 wrote:If you cant answer the question, then stop replying0
-
jaro84 wrote:Because Im forced to..
Anyway, I see no business requirement whatsoever to add a salesline when you're inserting a salesline on formlevel.
This looks like very bad practise (not to mention the hardcoded parts).
and will give you headaches if you implement this in a live environment.
If you think logically you'd already know why you don't get the document number in your variable.
Because salesheader is completely and utterly empty. It's just a variable of record sales header, but I bet you didn't even bother to fetch the salesheader before you've assigned it to docno. Which makes it a catch22 for you because you don't know the document number.
Anyways, I recommend to get some senior help, (if that's unavailable, then recommend hiring a consultant/company)
But please rethink your solution after you've had some more training in developing solutions in NAV 2009.0 -
jaro84 wrote:Because Im forced to..
its not enough to just enter the No. field.. If it was enough then there wasnt a problem.
If you cant answer the question, then stop replying
Wow! What a polite way to ask questions in a professional forum :thumbsdown:
As Sog says the problem seems more with the design of the solution you are developing rather than coding. Better ask for some real time help/guidance from senior colleagues/consultants.CA Sandeep Singla
http://ssdynamics.co.in0 -
jaro84 wrote:Because Im forced to..
its not enough to just enter the No. field.. If it was enough then there wasnt a problem.
If you cant answer the question, then stop replying
I think better to say is that if you don't want help, why are you asking a question? If you are forced to then do what ever you are being forced to do, and when it crashes later, just blame the person that forced you to do it.
Today it looks like I need to close mibuso and not read any posts or I will end up with a headache.David Singleton0 -
jaro84 wrote:Form - OnInsertRecord(BelowxRec : Boolean) : Boolean
Thats where im inserting the line..
SalesLine."Document Type" :=1;
SalesLine."Document No." := '1033';
SalesLine."Line No." := 20000;
SalesLine.Type := 2;
SalesLine."No." := '1';
As you see, I have hardcoded the Document No., it works fine.. But I instead of hardcoding, I want to get the Document No dynamically0 -
Basically what they are saying is that if explain your biz requirement and what & why you want to do this, perhaps we can point you in the proper direction on how to handle it correctly. But using on insert at form level and hardcoding is never a good path.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