Generating PDFs from Netsuite Sales Invoices
We have a need to generate PDFs based on invoices for a select set of item numbers in Netsuite and automatically transmit them to a partner. We were thinking this may be a good fit for a Celigo Flow (Netsuite Saved Search to identify the sales invoices --> Celigo Flow --> call to an API to generate each invoice --> pick up the invoices and send).
Wondering if anyone knows whether such functionality exists to generate PDFs to the Netsuite file cabinet via API, and whether it's accessible from Celigo?
0
Comments
Hey Wade,
You can write a SuiteScript preSend hook (pretty similar to preSavePage hook on IO), but it runs inside of NetSuite. You can configure a NetSuite export with a search that returns internal ids of the invoices whose PDF needs to be generated, then you can write a preSend hook in SuiteScript with the following sample code to generate PDF, store them in file cabinet and return the internalIds to IO.
This will have the PDFs in NS file cabinet and then you can configure another export to get these files from NS, send to destination and delete them from FileCabinet after export, if needed to save space using Purge File After Export.
Hi Wade Shelton,
We have this on our Salesforce-NetSuite integration app which we solved with some SuiteScript code. We are looking into how to solve this for you on a custom flow and should get back to you Monday. Thanks for letting us know about this need and for your patience!
Thank you both for the help.
We've been looking into using this method, and think we have all but one part of it figured out: How to pass in parameters for the SuiteScript in the PreSend hook.
I haven't seen any documentation on it. Since the suitescript obviously lives in Netsuite, how do we create an argument list to pass to the script?
For example - assuming a function called "DoSomething(param1,param2)" in a Netsuite Script with FileID 1, and assuming that I wanted to pass values from Field1 and Field 2 into param1 and param2, would the function call inside of Celigo look like this?
Hey Wade,
The preSend hook receives a set of options as defined here (similar to preSave hook).
You can review the debug logs in a RESTlet that comes with integrator.io bundle called "Celigo Realtime RESTlet Import Runner". It will give you a good idea on what parameters by default is passed by IO and should suffice all your needs
Though I not 100% sure of the usecase on why you need to pass parameters as you can always set them in your script, ie you script will always get all the search result set. Anyways, there are multiple ways to achieve hooks to receive parameters depending upon the usecase.
Mujtaba -
I appreciate all of the help, but unfortunately, we're still missing too many pieces here.
We have created the script in our Netsuite environment, and are working on the Saved Search for the invoices we need to generate, but are really lost on how to map the parameters from the Saved Search results into the function call.
In Celigo, I see this on the Presend hook. I don't see any place to place the javascript for the Presend hook that you referenced above, as it does not have the "pencil" edit icon like the PreSave Page (See highlights below)
In terms of your suggestion re: adding hardcoded text in a textformula inside the saved search, are you suggesting using that text formula to "create" the JSON object to hold the parameter values? If so, then I still don't see how to add that column to the function call?
Mujtaba -
Not sure if you're seeing these updates, but any help you (or anyone else at Celigo) could provide would be appreciated.
Thanks.
Hi Wade Shelton,
Apologies for the delay in response! You need to modify the NetSuite presend SuiteScript hook in NetSuite itself. SuiteScript hooks run in NetSuite, so integrator.io only lets you specify the ID of this hook, but you can't modify it in integrator.io.
Courtney
Thanks for the follow up, but I still think I'm missing something here.
So... I have an export that calls a saved search. That saved search holds the logic for which invoices I need to generate PDF invoices for... i.e. - each record in that saved search needs an invoice generated to PDF.
If the presend hook doesn't allow parameterization from the Celigo side, how do you call the script for each invoice returned by the saved search?
Best Practices when writing SuiteScript hooks
To your specific question, attach a hook say myPreSendHook via providing the fileId and function name to the NetSuite Export . The hook looks like below (check the above RestLet to view logs as you run the flow)
IO will automatically invoke this function and pass on the options (which contains data fetched from search in options.data). You can do your processing here, and then modify the data being returned. Keep in mind to also set a small pageSize on NS export to make sure that you have smaller data coming up in your hook (so that your don't run into NS governance issues of points) . The point it you entry point is the preSend hook function which gives you all the data it fetches per each export run and then you can call your own function from there.
To summarize, IO will invoke the preSend function for a group of records that are fetched by running the search .The group of records is determined by your batchSize/pageSize property set on export. The function is invoked only once per group , and you can write code in that function to generate pdfs for a group of invoices and send the invoice ids back to IO.
Let me know if this helps.
Please sign in to leave a comment.