RE: 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.

jomtos Rookie Asked on May 12, 2022 in SuiteScript.
Add Comment
11 Answers

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**

/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define([],
    function() {
        function beforeLoad(scriptContext) {
            try{
                if ((scriptContext.type).toLowerCase()  != ‘create’) {
                    var objTransactionForm = scriptContext.form
                    objTransactionForm.clientScriptFieldId = 9999; // ID clientscript field
                    objTransactionForm.addButton({
                        id          : ‘custpage_printinventorytransfer’,
                        label       : ‘Print’,
                        functionName: ‘printInventoryTransfer()’
                    });
                }
            }catch(e){
                log.error({
                    tittle: e.name,
                    details: e.message
                })};
        }
        return {
            beforeLoad: beforeLoad
        };
    });
**Client Script**
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */
define([
    ‘N/currentRecord’,
],
function(currentRecord) {
    function pageInit() {
    }
    function printInventoryTransfer() {
        var record = currentRecord.get();
        var recId = record.id;
        var recType = record.type
        var suiteletURL = url.resolveScript({
         scriptId:’customscriptcase3783737_suitelet’,//Please make sure to replace this with the script ID of your Suitelet
         deploymentId: ‘customdeploycase3783737_suitelet_dep’,//Please make sure to replace this with the deployment ID of your Suitelet
         params: {
     ‘recId’:recId,
    ‘recType’:recType
         }
         });
      document.location=suiteletURL;
         };
    return {
        pageInit : pageInit,
        printInventoryTransfer : printInventoryTransfer,
        };
    });
**Suitelet**
/**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 */
define([‘N/render’],
function(render) {
function returnPDF(scriptContext) {
    let renderer = render.create();
    renderer.setTemplateById({ id:52 });
    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());
}
  return {
    onRequest: returnPDF
  };
});
Thank you

 

 

Rookie Answered on May 23, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.