This topic contains 10 replies, has 0 voices, and was last updated by cgieselman 8 years, 10 months ago.

  • Author
    Posts
  • #2933

    GAJ

    Appreciate help on what the syntax would be to reference the original QUOTE # that created the Sales Order, from within the Invoice template.
    This is a cached copy. Click here to see the original post.

  • #2934

    ALAGARSAMY

    Hi Gaj,

    If you are using normal PDF Layout add a custom element text as {createdfrom.createdfrom} in the Invoice PDF Layout.

  • #2935

    GAJ

    Thank you Alagarsamy, works perfectly:

    From an Invoice PDF/HTML Template,

    ${record.createdfrom.createdfrom}

    returns

    Quote #FR-124641

    Can you also describe the NS syntax to LTRIM the “Quote #” string off the front?

    Would it be best done here in the template or in a Custom Transaction Body Field’s DEFAULT VALUE / Formula?

    Sorry I have to ask, can’t find working syntax examples and am on limited trial-and-error time.

    Gary

  • #2936

    michoel

    Try:

    Code:

    ${record.createdfrom.createdfrom?replace(‘Quote #’,”)}

    The documentation for the templating engine that NetSuite uses for generating Advanced PDF/HTML documents is available here:

    http://freemarker.incubator.apache.org/docs/index.html

  • #2937

    GAJ

    Thanks Michoel, it too worked perfectly:

    Code:

    ${record.createdfrom.createdfrom?replace(‘Quote #’,”)}

    Still, I need one more piece of syntax advice… turns out, since we are in a multi-language environment, English & French, the quote labels returned vary, e.g.

    Quote #FR-124641

    Devis #FR-124641

    What would syntax would you then use to return everything AFTER the # sign?

    Very much appreciate your time on this.

    Gary

  • #2938

    michoel

    You could do:

    Code:

    ${record.createdfrom.createdfrom?replace(‘Quote #’,”)?replace(‘Devis #’, ”)}

    Or using a regular expression, this might be cleaner (untested):

    Code:

    ${record.createdfrom.createdfrom?replace(‘^.+ #’, ”, ‘r’)}
  • #2939

    cgieselman

    Without meaning to hijack this thread, I’m trying to get the original order date to print on an invoice template. I can get

    Code:

    ${record.createdfrom.trandate}

    to return the date but it is in the format “YYYY/MM/DD hh:mm:ss” but the time value is all 0’s.

    I’ve tried

    Code:

    ${record.createdfrom.trandate?date(‘mm/dd/yyyy’)

    but I can’t save the template, I get the error “The string doesn’t match the expected date/time format. The string to parse was: “”. The expected format was: “mm/dd/yyyy”.”

    I can get rid of the time using the replace method above but that still leaves me with a date format that doesn’t match others on the sheet or what most of our customers are used to.

    Any help is appreciated.

  • #2940

    michoel

    The ‘date’ builtin actually does the opposite of what you are trying (converts a string to date, not date to string)

    Try:

    Code:

    ${record.createdfrom.trandate?string(‘mm/dd/yyyy’)

    You can also set this globally for the template:

    Code:

  • #2941

    cgieselman

    Originally posted by michoel

    View Post

    The ‘date’ builtin actually does the opposite of what you are trying (converts a string to date, not date to string)

    Try:

    Code:

    ${record.createdfrom.trandate?string(‘mm/dd/yyyy’)

    You can also set this globally for the template:

    Code:

    Michoel – I tried making the first suggested change and on save it gave me the error

    “Expected method. record.createdfrom.trandate?string evaluated instead to freemarker.template.SimpleScalar on line 207, column 50 in template.”

    I tried it with and without the ending “}” that I think is missing from your line but it didn’t like it either way (without the bracket it gave a different error complaining about the missing bracket).

    I’m not sure where the second line should go but I tried it within the tags as well as within the tags and it didn’t like either, giving the error

    “Parse exception during template merging freemarker.core.ParseException: Token manager error: freemarker.core.TokenMgrError: Unknown directive: #setting on line: 177, column: 441, in template: template in template”

    Any thoughts? Thanks for your help.

  • #2942

    michoel

    Hmm, seems like the ‘createdfrom.trandate’ field is actually a string, so you do want the ‘?date’ builtin to convert it to date. Though your mistake was trying to put the date format you wanted to output, while ?date requires the date format of the input string. The following should work:

    Code:
    ${record.createdfrom.trandate?date(‘yyyy-mm-dd hh:mm:ss’)}
    I am not sure why the date_format setting is not working for you. It works fine when I try..

  • #2943

    cgieselman

    Okay so I’ve made progress and it will work for my needs but now I’m curious why it is acting the way it is.

    I tried changing the ?date to specify the correct input format as you suggested but it resulted in the same error as I got above. Then I encapsulated the field value in an bracket to check if the length of the string ${record.createdfrom.trandate} was >0 and this allowed me to save and get the results I wanted on a test invoice.

    It seems to me that NetSuite is trying to validate every field on save and because it is returning null with regards to the created from transaction date and it is bricking. Would this behavior make sense to you?

    Anyways, thanks for the help.

You must be logged in to reply to this topic.