Create a quote form a new form

markyTmarkyT Member Posts: 120
Dear folks, I think this is easy for experts. I've create a new form that brings a "Contact Nº" and the "Customer No" asociates. Then, from this form I want to create a sales quote . I put a button with a PushAction and the following options:

PushAction: RunObject
RunObject: Form Sales Quote
RunFormLink: Sell-to Customer No.=FIELD("Customer No.")
RunFormLinkType: OnUpdate

"Customer No." is the field from my new form.

Well, on push the button it goes to the customer quotes, but it doesn't insert a new one. ¿which is what I need?.
Thanks in advance

Comments

  • lyotlyot Member Posts: 202
    edited 2010-05-10
    You should do everything in the OnPush trigger of the button:
    lrecSalesQuote.INIT;
    lrecSalesQuote.VALIDATE(Document Type,lrecSalesQuote."Document Type"::Quote);
    lrecSalesQuote."No. Series" := (Sales Quote No. Series);
    lrecSalesQuote.VALIDATE("Sell-to Customer No.",codCustomer);
    lrecSalesQuote.VALIDATE("Sell-to Contact,txtContact);
    lrecSalesQuote.INSERT(TRUE);
    
    FORM.RUN(41,lrecSalesQuote);
    

    Should be something like this... quickly coded, errors possible...
  • markyTmarkyT Member Posts: 120
    Thanks for reply. Only one question: lrecSalesQuote I suppose is Sales Header table?.
  • lyotlyot Member Posts: 202
  • markyTmarkyT Member Posts: 120
    Sorry, it says me "date is not correct" on push. What's the matter please?.
  • lyotlyot Member Posts: 202
    edited 2010-05-10
    Try this:
    lrecSalesQuote.INIT;
    lrecSalesQuote.VALIDATE(Document Type,lrecSalesQuote."Document Type"::Quote);
    //lrecSalesQuote."No. Series" := (Sales Quote No. Series);
    lrecSalesQuote."No." := '';
    lrecSalesQuote.VALIDATE("Sell-to Customer No.",codCustomer);
    lrecSalesQuote.VALIDATE("Sell-to Contact,txtContact);
    lrecSalesQuote.INSERT(TRUE);
    
    FORM.RUN(41,lrecSalesQuote);
    
  • markyTmarkyT Member Posts: 120
    Thanks, but the result is the same. It only works if I cancel the line:
    lrecSalesQuote.VALIDATE("Sell-to Customer No.",codCustomer);

    Then it insert a new Quote but doesn't put the customer number neither the other fields. Any idea please?
    Thanks.
  • lyotlyot Member Posts: 202
    Ok, what about this:
    lrecSalesQuote.INIT;
    lrecSalesQuote.VALIDATE(Document Type,lrecSalesQuote."Document Type"::Quote);
    //lrecSalesQuote."No. Series" := (Sales Quote No. Series);
    lrecSalesQuote."No." := '';
    lrecSalesQuote.VALIDATE("Sell-to Customer No.",codCustomer);
    lrecSalesQuote.VALIDATE("Sell-to Contact,txtContact);
    lrecSalesQuote.INSERT(TRUE);
    
    
    lfrmSalesQuote.SETRECORD(lrecSalesQuote);
    lfrmSalesQuote.RUN;
    
    

    Should work :?
  • markyTmarkyT Member Posts: 120
    Thanks for reply. Sorry, but it goes on showing the message "Date is not correct". I don't what it means.
    Thanks.
  • lyotlyot Member Posts: 202
    Enable the debugger and see on which line he gives the date error.
  • SavatageSavatage Member Posts: 7,142
    perhaps the # = blank is causing the problem.
    remove that line..we use something similar below & it works.

    OnPush()
    RECSALESHEADER.INIT;
    RECSALESHEADER."Document Type" := RECSALESHEADER."Document Type"::Order;
    RECSALESHEADER.VALIDATE("Sell-to Customer No.",'blah blah');
    RECSALESHEADER.INSERT(TRUE);
    SETFILTER("No.",RECSALESHEADER."No.");

    CurrForm.SalesLines.ACTIVATE;
    CLEAR(RECSALESHEADER."Document Type");
    CLEAR(RECSALESHEADER."No.");
  • BeliasBelias Member Posts: 2,998
    Following the common user inputs, i would do:
    RECSALESHEADER.INIT; 
    RECSALESHEADER."Document Type" := RECSALESHEADER."Document Type"::Order;//or whatever document type 
    RECSALESHEADER."no." := '';
    RECSALESHEADER.insert(true);
    RECSALESHEADER.validate("sell-to customer",'mycustomer);
    ...
    ...
    RECSALESHEADER.modify(true);
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • markyTmarkyT Member Posts: 120
    Perfect!! it runs. Finally this is the code:

    RECSALESHEADER.INIT;
    RECSALESHEADER.VALIDATE("Document Type",cabventa."Document Type"::Quote);
    RECSALESHEADER."No." := '';
    RECSALESHEADER.INSERT(TRUE);
    RECSALESHEADERVALIDATE("Sell-to Customer No.","Customer No.");
    RECSALESHEADER.MODIFY(TRUE);
    formsales.SETRECORD(RECSALESHEADER);
    formsales.RUN;

    Thanks everybody for help and time.
Sign In or Register to comment.