newb question

Hello,

I need to modify the data before it gets renderer by the template. (Specifically, the record only returns the units iid, so I need to separately look up the unit of measure text and insert it into the pdf).

The rendering uses the code below to render the PDF. Does anyone have an example of how to get the record contents first, and modify the data before it gets passed into the rendering engine? (or a different way if I’m on the wrong track already)

// Create the Renderer Object
let renderer = Nrender.create();
renderer.addRecord({
    record: record,
    templateName: 'record',
});
// Add the chose template to the renderer
renderer.setTemplateById(templateIid);
// Generate an XML String from the renderer
let xmlString = renderer.renderasString();
Rookie Asked on October 18, 2022 in SuiteScript.
Add Comment
1 Answer(s)

I would generally advise storing the value you want to display on the record itself.

For example, before you render the PDF you can look up the value you would like to display and use Nrecord.submitFields to store the value on the record if the value isn’t populated already.  Alternatively, if you are not concerned with historic data, you could have a User Event that populates the value on save of the afterSubmit of the record.

That way you can simply add the field reference to the template, rather than try to manipulate it before rendering.

Beginner Answered on October 18, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor