Copy records from one quote to another

hairyjimhairyjim Member Posts: 99
edited 2005-09-19 in Navision Attain
I have been working on additional functionality to the 'copy document' functionality within 3.6 in the below thread.

http://www.mibuso.com/forum/viewtopic.php?t=7661

I have got this sorted with some good help.

My questions kind of follows on from that above.

Each quote within my system has footer comments that can be can be printed at the bottom of the quote. This works well.

I created a new table for this with the following fields:
Language, Document No., Type, Line No. and description

When I use the copy quote functionality I would like to copy the footer comments over to the new quote. I am relativly new to Navision and I am not sure what I need to look at within Navision to get me started on doing this. Could someone point me in the right direction please.
Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.

Answers

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    This will not be a suprise I hope, but I will point you in the same direction as last time.

    Codeunit 6620

    Look for this section of code
          END;
      END;
      
      NEWFUNCTIONHERE
    
    END;
    
    IF MoveNegLines THEN
      DeleteSalesLinesWithNegQty(FromSalesHeader,FALSE);
    
    IF LinesNotCopied > 0 THEN
      MESSAGE(Text004);
    

    Put a new function to copy your table at NEWFUNCTIONHERE.
  • hairyjimhairyjim Member Posts: 99
    So am I thinking along the right lines I can use the TRANSFERFIELDS functionality?

    Having no development documentation and just the help within navision for cside is a little limiting.
    Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You can use TRANSFERFIELDS if both tables have the same field structure.

    In this case I think you can.
  • hairyjimhairyjim Member Posts: 99
    Yeah sorry the data is in the same table. Basically just duplicating lines associated with one quote but attaching them to another quote.

    It would be like the copysaleslines function within this code unit I guess
    Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Yes, the function should look like the copysaleslines function.

    Just keep it as basic as possible if it is just customisation.
  • hairyjimhairyjim Member Posts: 99
    OK. I have got somewhere with this.

    I created two local record variables to the CopySalesDoc function; ToFooter & FromFooter

    There is a case statement, which at the very top defines several conditions
      CASE FromDocType OF
        //SalesDocType::Quote,
        SalesDocType::"Blanket Order",
        SalesDocType::Order,
        SalesDocType::Invoice,
        SalesDocType::"Return Order",
        SalesDocType::"Credit Memo":
    

    As you can see I commented out the Quote one and I created a new statement at the end solely for Quote:
        SalesDocType::"QUOTE":
          BEGIN
            ItemChargeAssgntNextLineNo := 0;
            FromSalesLine.RESET;
            FromSalesLine.SETRANGE("Document Type",FromSalesHeader."Document Type");
            FromSalesLine.SETRANGE("Document No.",FromSalesHeader."No.");
            IF MoveNegLines THEN
              FromSalesLine.SETFILTER(Quantity,'<=0');
            IF FromSalesLine.FIND('-') THEN
              REPEAT
                CopySalesLine(ToSalesHeader,ToSalesLine,FromSalesHeader,FromSalesLine,NextLineNo,LinesNotCopied,0);
                CopyFromSalesDocDimToLine(ToSalesLine,FromSalesLine);
                IF FromSalesLine.Type = FromSalesLine.Type::"Charge (Item)" THEN
                  CopyFromSalesDocAssgntToLine(ToSalesLine,FromSalesLine,ItemChargeAssgntNextLineNo);
              UNTIL FromSalesLine.NEXT = 0;
    
          // Copy footer comments
          FromFooter.RESET;
          FromFooter.SETRANGE("Document No.",FromSalesHeader."No.");
            IF FromFooter.FIND('-') THEN
              REPEAT
                ToFooter."Document No." := FromSalesHeader."No.";
                ToFooter."Type" := 1;
                ToFooter."Line No." := FromFooter."Line No.";
                ToFooter."Description" := FromFooter."Description";
              UNTIL FromFooter.NEXT = 0;
    
          // End Copy footer comments
    
          END;
    

    The main thing I tried to do is at the bottom of the quote case statement. This is where I attempted to create the copying of the comment lines, it does not seem to work. Nothing seems to happen at all.

    Could you point out what I have attempted to do wrong please. To be honest I thought I had done it right.
    Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Maybe a ToFooter.INSERT will help :D
  • hairyjimhairyjim Member Posts: 99
    Ahh great - yes obvious now you told me :oops:

    But I now get the following error:

    The Header / Footer already exists
    Identification and values:
    Table='Quote',Language Code='',Document No.='SQ06898',Type='Footer Notes',Line No.='1000'

    I added the insert at the end of the statements for this seem to be the only way it seem to try and work:
                ToFooter."Table" := FromFooter."Table";
                ToFooter."Document No." := ToSalesHeader."No.";
                ToFooter."Type" := 1;
                ToFooter."Line No." := FromFooter."Line No.";
                ToFooter."Description" := FromFooter."Description";
                ToFooter.insert(TRUE);
    

    Any thoughts?
    Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
  • hairyjimhairyjim Member Posts: 99
    It would help if I specified the lannguage code! All fixed - thanks for helping me get there Mark!

    Jim
    Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    OK, congratulations and on to the next chalenge :D
Sign In or Register to comment.