How to add Item no and description on Sales List form

Markandey_PandeyMarkandey_Pandey Member Posts: 178
Hi experts

can we create a List form from tow tables, if yes then how, can anybody guide me.

Actually i want to add Item Description on Sales List form.....................
Markandey Pandey

Comments

  • MBergerMBerger Member Posts: 413
    and how do you want to do that ? there can be more than 1 line on a sales document, so there is no such things as THE item description to show there.

    if you just want the first then there are several ways to accomplish that :
    - Add code in the OnAfterGetRecord of the form to collect the description you want to show into a global variable, and add that var. to the form.
    - Add a function to the Sales header table that does the same as the above, and add that function in a field on the form.
  • matttraxmatttrax Member Posts: 2,309
    MBerger wrote:
    if you just want the first then there are several ways to accomplish that :
    - Add code in the OnAfterGetRecord of the form to collect the description you want to show into a global variable, and add that var. to the form.
    - Add a function to the Sales header table that does the same as the above, and add that function in a field on the form.

    Valid ways, but don't write code if you don't have to. A simple flowfield will do the trick...that is if you do really just want the first description.
  • lvanvugtlvanvugt Member Posts: 774
    If really needed and on SQL Server you can create a (join) view on SQL Server and create a NAV form based on that view.

    I've done that in the past. With some knowledge of SQL Server views and how to create a NAV form for that, it's not that difficult.

    But I also would ask: why would you want that?
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    lvanvugt wrote:
    If really needed and on SQL Server you can create a (join) view on SQL Server and create a NAV form based on that view.

    I've done that in the past. With some knowledge of SQL Server views and how to create a NAV form for that, it's not that difficult.

    But I also would ask: why would you want that?


    That i can do but i am using the Native Database.
    Markandey Pandey
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    MBerger wrote:
    and how do you want to do that ? there can be more than 1 line on a sales document, so there is no such things as THE item description to show there.

    if you just want the first then there are several ways to accomplish that :
    - Add code in the OnAfterGetRecord of the form to collect the description you want to show into a global variable, and add that var. to the form.
    - Add a function to the Sales header table that does the same as the above, and add that function in a field on the form.


    As i am new to navision can u pls give me the code for both schenario.
    Markandey Pandey
  • vijay_gvijay_g Member Posts: 884
    As expert said, do not try to go typical just take a rec var for item and show description to help it like
    Recitem.get("sales line".no);
    and write in text box recitem.description.
    i think it would be helpful to u.
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    vijay_g wrote:
    As expert said, do not try to go typical just take a rec var for item and show description to help it like
    Recitem.get("sales line".no);
    and write in text box recitem.description.
    i think it would be helpful to u.


    hi thanx for the reply, i got the point but if i am doing so i am getting an error "Item No. does not exist"
    can u plz tell me the reason
    Markandey Pandey
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    vijay_g wrote:
    As expert said, do not try to go typical just take a rec var for item and show description to help it like
    Recitem.get("sales line".no);
    and write in text box recitem.description.
    i think it would be helpful to u.


    Hi i have declared to global rec variables and one text variable

    ItemRec-> Item
    SalesLine->Sale Line
    Description->Text

    and have written the following code:


    Item.GET("Sales Line"."No.");
    Description:=SalesLine.Description;

    here i have assigned description as source expr to text box but its giving an error when i am running the form.

    i have also tried this Textbox->source expr-> ItemRec.Description

    plz suggest me the soln
    Markandey Pandey
  • smic1983smic1983 Member Posts: 27
    lvanvugt wrote:
    If really needed and on SQL Server you can create a (join) view on SQL Server and create a NAV form based on that view.

    I've done that in the past. With some knowledge of SQL Server views and how to create a NAV form for that, it's not that difficult.

    But I also would ask: why would you want that?

    Hi lvanvugt,
    Kindly explain how to create Nav Form based on View created in Sql Server.
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    Hi experts,

    Actually according to our client requirement i want to add Item No and Description on the sales list form. plz note that there will be only one item per Sales order.

    here i have created two fields "Item No." and "Item Description" on Sales Header table and had written the following code in OnPush trigger on Release Menu Item:


    SalesHeader.RESET;
    SalesHeader.SETRANGE("No.",SalesLine."Document No.");
    SalesHeader.SETRANGE(SalesHeader."No.","No.");


    SalesHeader."Item No.":=SalesLine."No."; // I had also tried putting constant here
    SalesHeader."Item Description":=SalesLine.Description;
    SalesHeader.MODIFY;

    Am i going on right track, can anybody suggest me the proper solution as i have been frusted doing this from last one week.
    Markandey Pandey
  • kinekine Member Posts: 12,562
    1) I will not comment the "why" for that and the "what if you have more lines"... ;-)
    2) You can use GET on the header, you know exactly the primary key, do not use SETRANGE/SETFILTER and FIND when you knwo primary keys values.
    3) Look at this your code:
    alesHeader.RESET;
    SalesHeader.SETRANGE("No.",SalesLine."Document No.");
    SalesHeader.SETRANGE(SalesHeader."No.","No.");
    
    SalesHeader."Item No.":=SalesLine."No."; // I had also tried putting constant here
    SalesHeader."Item Description":=SalesLine.Description;
    SalesHeader.MODIFY;
    
    You are setting two filters on same field of SalesHeader... ;-) What is Rec in this code? If I "clean" this code, it looks like:
    alesHeader.RESET;
    SalesHeader.SETRANGE("No.",SalesLine."Document No.");
    SalesHeader.SETRANGE("No.","No.");
    
    SalesHeader."Item No.":=SalesLine."No."; // I had also tried putting constant here
    SalesHeader."Item Description":=SalesLine.Description;
    SalesHeader.MODIFY;
    
    Can you see the problem? ;-)
    And there is one thing - you are filtering and then modifying, what about reading the record first before you modify it? (GET) :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • lvanvugtlvanvugt Member Posts: 774
    See my blog post I just created: http://dynamicsuser.net/blogs/vanvugt/archive/2009/12/03/using-sql-views-in-nav.aspx.

    Hope it makes sense. :P
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    Actually what i want it to update item no and description from line to header becoz i have to add these to fields on Sales List form.

    can u plz help me.
    Markandey Pandey
  • kinekine Member Posts: 12,562
    And have you read my post? What is still unclear for you?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,110
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    hi all

    thanx for ur valuable support, issue is resolved.
    Markandey Pandey
Sign In or Register to comment.