Has anyone ever added a button to a transaction an...
# suitescript
n
Has anyone ever added a button to a transaction and, using the adv print template, generated an Excel file instead of PDF? (I do not mean a CSV) I suspect I can use the N/render module and manipulate the content but thought I'd ask here in case there's a simple way to do it. TIA.
c
@NElliott CloudExtend Excel for NetSuite can do this. From Excel, you enter the internalID of the record and click refresh and the record will be returned to Excel (and can even be edited). sorry for the DM - I do not want to be salesy in the channel as I work at CloudExtend.
There is a free trial as well
n
You're talking about accessing the record from Excel, I'm talking about creating an Excel file using advanced templates to create an Excel file. Unless I'm misunderstanding I don't believe what you're suggesting is the same functionality. Thanks for replying though.
j
I've created a custom field that holds a link to a saved search which also dynamically adds parameters in the url narrowing down to that specific record and then tacks "&csv=Export&OfficeXML=T" on the end. This will load the saved search, add the filtering parameters of the record you are on and download the excel file. I believe this is what you are looking to do?
s
@jarens That sounds like it would basically be a csv and not use the advanced template he wants to use?
j
I believe there are parameters in the url you can define csv or excel
Had to check my cheat sheet. "&OfficeXML=T" is the portion that dictates downloading as excel @Sandii.
e
@jarens your approach is excellent in case the data @NElliott will display can all be in the saved search.
//Create Excel file
var xmlStringEncoded = encode.convert({
string: xmlString,
inputEncoding: encode.Encoding.UTF_8,
outputEncoding: encode.Encoding.BASE_64
});
var excelFile = file.create({
name: ScriptVariables.CSV_FILE_NAME,
fileType: file.Type.EXCEL,
contents: xmlStringEncoded
});
The code above will let you generate a excel file but you need to create your XML as string in the format of Workbooks tag (excel format) in case you need to process and calculate data, I do not have that portion of code.
n
@jarens @eminero Thank you both for your replies. The saved search route will not allow me to format the output as I'd like (I suspect) but it's an interesting approach! The code you provided @eminero looks like it could work well, I just wonder how I might apply the adv print template. Maybe I could employ n/render to create the input to that process.
e
Oh, I did not pay attention to the adv print template, I am not sure about that.
n
Basically they want what you see in the PDf when you'd normally hit print but in Excel format from a different button press.
e
I would create a new custom button for this particular excel file. or hide/remove the original and display with the same name the new one.
n
Yeah that's what I've been saying 🙂 I am adding a button but I don't know how to employ the pdf template to generate the excel. I already added a button, call a suitelet and n/render the transaction as HTML using the template via a suitelet and that generated content is downloaded
r
If I understand correctly, Excel uses a different XML definition so you will need to "translate" your PDF template to an Excel XML file.