Get Document No from salesheader

jaro84jaro84 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?

Comments

  • jaro84jaro84 Member Posts: 17
    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 DocNo
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    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?
  • jaro84jaro84 Member Posts: 17
    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
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    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?

    Why do you want to do this?
    As soon as you enter No. field in Subform..all the common fields will be inserted automatically..
  • jaro84jaro84 Member Posts: 17
    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
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    jaro84 wrote:
    If you cant answer the question, then stop replying
    Yes, I cant answer to questions which doesnt have a meaning.. :mrgreen:
  • SogSog Member Posts: 1,023
    jaro84 wrote:
    Because Im forced to..
    Is somebody holding a gun to your head?

    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.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • ssinglassingla Member Posts: 2,973
    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.in
  • David_SingletonDavid_Singleton Member Posts: 5,479
    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 Singleton
  • rhpntrhpnt Member Posts: 688
    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
    Dear jaro84, it's obvious that you don't have a clue what your'e doing. A true NAV expert can never be forced into doing something that does not comply to NAV standards. A (this) forum is no place to ask questions which are allready answered a houndred times in numerous NAV docs available online. And one more advice, if an MVP answers with a question then it sure has a meaning. Just cool down and tell us the whole story.
  • SavatageSavatage Member Posts: 7,142
    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.
Sign In or Register to comment.