Custom Print Button in Inventory Transfer
Hello
I need some guidance in setting up a custom print button in the inventory transfer form, I see the form has the printing field but the form itself doesn’t have the print button.
Any help would be appreciated.
You should be able to add a button using a User Event script.
You’ll also need an accompanying client script to handle the button action.
Please let me know if you need further details.
Yes, I was able to create the button with a user event. How can I make the CS so the button can call it?
Thanks for answering.
Best
Hi,
First, you need to reference a client script using:
form.clientScriptModulePath = './client_script.js';
When you add the button in the User Event script, there is a functionName argument.
The client script needs to implement that function.
Thanks,
Chris
I see but what module do I need to use to print? that’s the part I get lost. Now I know how to call the UE but how to print?
Thank you for your time.
Hi,
To do the actual printing you’ll need to use that client script function to call a Suitelet and in the Suitelet, do something like this:
let renderer = render.create(); renderer.setTemplateById({ id:123 }); ... scriptContext.response.addHeader({ name: 'Content-Type:', value: 'application/pdf' }); scriptContext.response.addHeader({ name: 'Content-Disposition', value: 'inline; filename=”Test.pdf"' }); scriptContext.response.writeFile(renderer.renderAsPdf());
Hello Again, I tried to build the script but I’ve failed, would you please help me find the issue? below the UE, SC, suitelet.
**User Event**
Hi,
It’s looking like you have all the main parts. One thing that springs out is that I’d expect to see:
functionName: ‘printInventoryTransfer’ (without the braces)
How far are you getting and is there any error?
Thanks,
Chris
It does nothing when I click on the button
Thanks for answering
If you open the Developer Tools Console in your browser, do you see any error message?