SCM Mobile Scripts for Printing
SCM Mobile provides the RESTlet that runs the print action to submit a print request from a NetSuite page. In your client script, you can call this RESTlet through the following details:
-
customscript_print_rl_trigger_print-Internal ID of the script record
-
customdeploy_print_rl_trigger_print-Internal ID of the script deployment record
For more information, see Adding a Print Button to a Custom Form or Adding a Print Button to NetSuite Pages.
SCM Mobile also provides the following sample scripts for invoking the RESTlet, which you can use as reference when you create your own scripts:
-
custom_cs_direct_printing.js -A sample client script that contains the callingPrintDirectly function, which invokes the RESTlet for printing. It also contains the input parameters passed to the RESTlet.
The following sample code for the function references the SCM Mobile RESTlet:
function callingPrintDirectly(){ console.dir(context) var genericRestlerURL = url.resolveScript({ scriptId: 'customscript_print_rl_trigger_print', deploymentId: 'customdeploy_print_rl_trigger_print', returnExternalUrl: false, });
-
custom_ue_direct_printing.js -A user event script that creates and adds a print button to a NetSuite record. The print button calls the callingPrintDirectly function of the client script.
If you choose to configure printing though a user event, you can create a similar script that adds the button and calls the function. See Adding Print Buttons Through a User Event Script.
Using the Administrator role, you can access and view the sample scripts by going to Customization > Scripting > Scripts.
When you create your client script, make sure that you add the input parameters that you want to pass to the RESTlet. These parameters capture your printing preferences and print template details, as shown in the following table:
Input Parameter Key |
Data Type |
Sample Value |
Required? |
Description |
---|---|---|---|---|
isDirectPrinting |
Boolean |
true |
Yes |
Set this parameter to true to indicate that you want to invoke a print action directly through the NetSuite UI and not from a mobile app. |
template |
String |
PrintTemplate1 |
Yes |
Name of the print template in XML format or the advanced PDF template. To view the sample print templates used in Mobile Printing, see SCM Mobile Printing. |
noOfCopies |
Numeric |
1 |
Yes |
Default number of copies that you want to print. |
printer |
String |
Printer1 |
Yes |
Name of the default printer. To view the list of your available printers, see Setting Up Your Printers. |
sourceId |
String |
customrecord_ |
Yes |
The ID of the NetSuite record or saved search that contains the data you use in your print template. For more information about print templates, see Creating Custom Print Templates and Files. |
sourceRowId |
Numeric |
1 |
Yes, if your source is a record |
The internal ID of the specific row from the source record that you specify in the sourceId parameter. For example, enter 1 for the row’s internal ID to print the data from the first row of the record. |
searchFilters |
Array of search filter objects |
[{ name: 'internalid', operator : search.Operator.IS, values : '1' }] |
Yes, if your source is a saved search |
The list of search filters that you want to apply to the saved search. See search.createFilter(options). |
results |
String |
record |
No |
The name of the object that stores the record’s data or saved search results. Make sure that you provide the name used in the associated print template. If you do not include this parameter, the RESTlet uses the default result value. In this case, the associated print template must use this value to access data from fields. |
In the following sample code, you can view examples of input parameter values for a source record:
// sample post object with a standard NetSuite record ID as sourceId
postObject['params'] = {
'isDirectPrinting':'true',
'template':'Template3',
'noOfCopies':'1',
'printer':'Microsoft Print to PDF',
'sourceId':'itemreceipt',
'sourceRowId':sourceRowID,
'resultsNameInTemplate':'searchResults'
});