How to List Posted Invoice on Posted Shipment Form

selece28selece28 Member Posts: 316
Hi Nav Masters,

My client wants me to display The List of Posted Invoice on the Posted Shipment Form.
For Shipment done from Sales Order by posting Ship, i can do.
I just create a new flow field on the Sales Shipment Header and COUNT the Sales Invoice Header and link it with Order No.

Then some problems occur.
If the user posting Invoice from Sales Invoice then the Order No. field will be blank.
Also If the user Posting from Sales Invoice with Get Shipment Line, the Order No. is empty too.

My question is, is there any link between the posted Invoice and Posted Shipment?

I think of creating a new Table to keep the relation between Shipment and Invoice that is not posted from Sales Order

The fields will consist of:
1. Shipment No (code)
2. Invoice No (code)
3. Posted from Sales Invoice (boolean)

I keep the Shipment No. and Invoice No. everytime posting from Sales Invoice. But there's more problems, how to get the Shipment No. when Get Shipment Line??? ](*,) ](*,) ](*,)

Is there any other better idea?

Please help me.

Thanks in advance,
______________

Regards,
Steven

Answers

  • ArhontisArhontis Member Posts: 667
    I recommend a custom lookup from the shipment header (with a button maybe) that finds and shows all the invoices of a shipment.

    To find the invoices of a shipment then you must find all the Item Ledger Entry of that shipment, (by filtering the Item Ledger Entry Table with document no. and posting date), then get every Value Entry for each Item Ledger Entry. The Value Entries are created from invoices, so by getting the "Document No." and the "Posting Date" of all those value entry records, you will have all your invoices.

    Since an invoice may have posted alot value entry records, then you could use a record of Sales Invoice Header to find the appropriate invoice (with document no. and posting date) and MARK it, then apply a filter MARKEDONLY and then show the posted invoices list...

    You could also make a integer variable on the shipment form and calculate the number of the records that you got marked and show it on the form so that the user can know how many invoices the shipment has. The lookup i menthioned earlier could be in the drill down of that control that shows the invoices count that you calculated (maybe in the onAfterGetRecord trigger of the form)

    All this was just an idea, and I think it is a lot simpler than modifying codeunits and creating new tables...

    Anyway, I hope I helped...
  • selece28selece28 Member Posts: 316
    Ow i think this is a better idea, but could you be more specific?
    Yes i want to display using integer to count the total invoice a shipment have.

    Please explain more with codes, coz i'm new in Nav and i dont know how to use MARK

    Thanks in advance
    ______________

    Regards,
    Steven
  • ArhontisArhontis Member Posts: 667
    Hi,

    Use the C/Side help to see at the MARK, MARKEDONLY and CLEARMARKS, it is best to seeit for yourself... :)

    I will write you the link between the tables:
    - Sales Shipment Header -> Item Ledger Entry
    Filter the "Document No." and "Posting Date" fields of Item Ledger Entry table with the "No." and "Posting Date" of the shipment header.
    - Item Ledger Entry -> Value Entry
    Filter the "Item Ledger Entry No." of the Value Entry for each Item Ledger Entry with the "Entry No." of Item Ledger Entry record (by using a loop).

    The "Document No." and the "Posting Date" of all the Value Entry that you will find will give you all the invoices...

    Code sample:
    VAR
      ILE:Record of Item Ledger Entry
      VE: Record of Value Entry
      SalesInvoiceHeader: Record of Sales Invoice Header
      CalcNumOfInvocies: Integer
    
    SalesInvoiceHeader.CLEARMARKS;
    ILE.SETRANGE("Document No.","No.");
    ILE.SETRANGE("Posting Date","Posting Date");
    IF ILE.FIND('-') THEN REPEAT//loop through all the item ledger entries of shipment
      VE.SETRANGE("Item Ledger Entry No.",ILE."Entry No.");
      IF VE.FIND('-') THEN REPEAT//loop through all the value entries of an ILE
        IF SalesInvoiceHeader.GET(VE."Document No.") THEN
          SalesInvoiceHeader.MARK(TRUE);
      UNTIL VE.NEXT = 0;
    UNTIL ILE.NEXT = 0; 
    SalesInvoiceHeader.MARKEDONLY;//show only the marked invoices
    CalcNumOfInvocies := SalesInvoiceHeader.COUNT;
    FORM.RUNMODAL(0,SalesInvoiceHeader);//show the default form
    
    This finds and shows a form with all the invoices of a shipment and the variable CalcNumOfInvoices holds the number of invoices that where found...

    I haven't tested it but I think it will work just fine... Just place the above code in a button on the shipments form to test it...

    Study the code and understand how it works...
    And remember, practice makes perfect...

    NOTE:
    You can always replace the FIND('-') with FINDSET(FALSE,FALSE) to increase speed...
  • selece28selece28 Member Posts: 316
    Hi Arhontis
    Thanks for your explanation,
    i tried your code,
    i make a function "CalcInvoice" to run your code (without using the FORM.RUNMODAL coz i just want to display the total of invoice on my Posted Shipment form).
    After the user click the DrillDown button the it shows the list of the invoice.

    I call the function "CalcInvoice" from <Form - OnAfterGetRecord()>

    Then i create a new text box with DrillDown properties set to Yes
    and set the SourceExpr properties to my countInv variable.

    But it still display all total Invoice, not only the invoice for that Shipment.

    Is there any mistake that i make?
    ______________

    Regards,
    Steven
  • ArhontisArhontis Member Posts: 667
    Oops, use the MARKEDONLY(TRUE);

    Look at the C/SIDE help on the menu and look for the MARK, CLEARMARKS and MARKEDONLY functions, so that you can learn more about it and be able to use it more in the future...
    :)
  • selece28selece28 Member Posts: 316
    yes i tried, its because the MARKEDONLY(TRUE);

    No i manage to display the total Invoice count for a Shipment
    Now how to make the DrillDown show the list of invoice for that Shipment.
    Do i need to create a new Form?

    Thanks in advance
    ______________

    Regards,
    Steven
  • vikram7_dabasvikram7_dabas Member Posts: 611
    I have done it.make on posted shipment form there is one menu button i have add 1 menu item says Posted invoice in the caption write any name in action field writ runobject and in run oject field write Form Posted Sales Invoices compile it and save it then u can open the posted sales invoice list.if it is right then please tell me
    Vikram Dabas
    Navision Technical Consultant
  • ArhontisArhontis Member Posts: 667
    Nope, write the same code in the OnDrillDown function of the control that keeps the number of the invoices and use the FORM.RUNMODAL(0,SalesInvoiceHeader);

    That will run the appropriate form... If you need to use another form the replace the 0 with the report ID you want...

    In general it is not proper to write code in forms, so finally I suggest you put all the code you wrote as function in a custom codeunit and call it from your form...

    Anyway... I am glad you made it is working... :)
    Please edit your first post and place a SOLVED: at the beginning of the subject...
  • selece28selece28 Member Posts: 316
    Yes vikram7_dabas, this i know, but this displays all Invoices.

    My problems solved,
    I use global variable for all variable in my "CalcInvoice" function

    So on <Form - OnAfterGetRecord()> i call that function

    and on <OnDrillDown()> i use only the :
    FORM.RUNMODAL(0,SalesInvHeader);

    And its all done..

    Thank you all, for helping me to solve this problems
    ______________

    Regards,
    Steven
  • ArhontisArhontis Member Posts: 667
    Hi Selece,

    I wanted to mention using global variable about the sales invoice header and just call the FORM.RUNMODAL, but as I mentioned it is not proper... I know that it is the easiest solution, but better implementation is using local variables in the function and placing the code in a cu or as a function in the table object (Sales Shipment Header) and use return value or return parameters of the function to get stuff out of it...

    I am glad to be of help... :)
  • selece28selece28 Member Posts: 316
    But i don't get it? Why Arhontis?
    If i code in Form, i only export 1 object to import to my client. Form 130 Posted Sales Shipment.

    If i create a cu or place in table, i need to export and import more than 1 objects?

    Maybe you can explain me?

    Thanks
    ______________

    Regards,
    Steven
  • ArhontisArhontis Member Posts: 667
    MBS suggest not to place code in forms but keep it organized...
    It is easier to handle migrations that way... (moving to new versions in Nav)
    In addition another developer would understand better on what you are trying to do...

    Nav has a lot of standards like that and I think there is a pdf document about it. Have studied it a few years ago.

    Have you read it?
  • selece28selece28 Member Posts: 316
    No i have not read it.
    I'm still new so i don't know bout that.
    I there any website where i can download the pdf file?

    Thanks
    ______________

    Regards,
    Steven
  • ArhontisArhontis Member Posts: 667
    Take a look on some mibuso posts:
    http://www.mibuso.com/forum/viewtopic.p ... =gui+guide
    http://www.mibuso.com/forum/viewtopic.p ... =gui+guide

    You can find the cal guide that describes a lot that you might find very useful is in the Tools CD:
    3.70:
    https://mbs.microsoft.com/partnersource ... page=false
    4.0 (the cal guide is missing on 4.0 so look in the 3.70):
    https://mbs.microsoft.com/partnersource ... page=false
  • selece28selece28 Member Posts: 316
    ok, i get it. Thanks for the information.
    It helps me a lot.
    Another question, if i put the code in my table. I just call it as a function. Or i create a new Integer field to keep the total count of Invoices for that Shipment. Just curious, can we create a flowfield but use c/al code as the CalcFormula?

    Thanks
    ______________

    Regards,
    Steven
  • ArhontisArhontis Member Posts: 667
    Not in that case... It is a little complicated and can't create a CalcFormula to count your invoices... CalcFields are a little standard... So you must make a function, just like the one you have in the form... :)
Sign In or Register to comment.