New line in text constant using STRSUBSTNO

notadevnotadev Member Posts: 5
edited 2017-11-20 in NAV Three Tier
Hi all,

I'm trying to add aditional information to a sales invoice when using "get shipment lines".
The first line is always the "shipment no" and is found in table 111: SalesLine.Description := STRSUBSTNO(Text000,"Document No.");
I would like to add a second line with the customer reference and external doc no.
SalesLine.Description := STRSUBSTNO(Text000,"Document No.","Customer Order Reference","External Document No.")
I tried all possible solutions to insert a new line, but none seem to work in this case. And almost all hits on google refer to RDLC...

Can someone point me in the right direction please?

//Edit: I'm looking for a solution to display in a page, not a report.

Best Answer

Answers

  • loggerlogger Member Posts: 126
    Hi @notadev ,
    What is content of you Text000? Maybe, you just need to extend it by new references to newly added parameters?
    Let's go!
  • notadevnotadev Member Posts: 5
    The original Text000 is just "Shipment No. %1"

    With "Shipment No. %1 %2 %3" I can get all the data on one line. So data retrieval is no problem.
    For the new line I tried with \, \\, \n, LF, CR, CRLF,.... in both the text constant and the code.
  • loggerlogger Member Posts: 126
    @notadev , aah, interesting. And where do you want to see these multiline text - on the page or on the report? If on the page, I'm not sure that it's possible using standard page elements as they do not support multiline. To make thing more clear, you can attach the screenshot to your answers.
    Let's go!
  • latronamarranlatronamarran Member Posts: 24
    edited 2017-11-20
    i believe you need to insert two new sales lines after the "shipment no" line with init-insert statements. also you need two new text global variables. the carriage returns are not what you're looking for.
  • loggerlogger Member Posts: 126
    @latronamarran , totally agree. This is the easiest way to reach desired result as I got it.
    Let's go!
  • notadevnotadev Member Posts: 5
    Thank you both for your answers. Unfortunately I'm totally lost now. I can't figure out how to add the second sales line.
    This is the current code:
    SETRANGE("Document No.","Document No.");
    Rec.CALCFIELDS("Customer Order Reference");
    Rec.CALCFIELDS("External Document No.");
    TempSalesLine := SalesLine;
    IF SalesLine.FIND('+') THEN
      NextLineNo := SalesLine."Line No." + 10000
    ELSE
      NextLineNo := 10000;
    
    IF SalesInvHeader."No." <> TempSalesLine."Document No." THEN
      SalesInvHeader.GET(TempSalesLine."Document Type",TempSalesLine."Document No.");
    
    IF SalesLine."Shipment No." <> "Document No." THEN BEGIN
      SalesLine.INIT;
      SalesLine."Line No." := NextLineNo;
      SalesLine."Document Type" := TempSalesLine."Document Type";
      SalesLine."Document No." := TempSalesLine."Document No.";
      LanguageManagement.SetGlobalLanguageByCode(SalesInvHeader."Language Code");
      SalesLine.Description := STRSUBSTNO(Text000,"Document No.");
      LanguageManagement.RestoreGlobalLanguage;
      SalesLine.INSERT;
      NextLineNo := NextLineNo + 10000;
    END;
    
  • notadevnotadev Member Posts: 5
    That is exactly what I needed. Thank you so much!
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    To get a new line character you must 'build it' manually, one way of making it up is something like this:
    NL := '  '; //two spaces here
    NL[1] := 13;
    NL[2] := 10
    
    NL is Text[2] variable

    Then you can the use it like this:
    SalesLine.Description := STRSUBSTNO(Text000,"Document No.", NL, "Customer Order Reference","External Document No.")
    
    Text000 would be then "Shipment No. %1%2%3 %4"

    You may need to change properties of the field used to display the SalesLine.Description on your RDLC report to enable Multiline on it.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.