Debugging Your Scriptable Cart with SuiteScript
To obtain debug messages, typically you must use record-level deployments. The steps below describe how to use a form-level deployment to generate debugging messages.
-
Go to Customization > Forms > Transaction Forms.
-
Customize a Standard Sales Order -Invoice, and a Standard Sales Order -Cash Sale form. Do not include custom code on either form. You will use these for testing.
-
After you create the two new forms, make a note of their Internal IDs.
-
-
Create an alternate version of your scriptable cart script. Keep your original script as your backup.
At the top of each event function, add the following code:
if (nlapiGetFieldValue('customform') != '[InternalID of Sales Order - Invoice from Step 1]' && nlapiGetFieldValue('customform') != '[InternalID of Sales Order - CashSale from Step 1]' { return; }
This code ensures that the script only fires for the sales order forms you are using on the web store.
Note:Use an nlapiLogExecution() call each time you want to output a debugging message.
-
Create a new client script, and then deploy it for all sales order forms.
-
Go to Customization > Scripting > Scripts > New > Client Script.
-
Enter event functions, and attach any library scripts.
-
On the Deployments subtab, in the Applies to column, select Sales Orders.
-
Click Save & Deploy.
-
On the Audience subtab of the script deployment record, make sure that Customer Center is selected.
-
-
Select the newly created sales order forms as the Scriptable Template for your web store.
-
Go to Commerce > Websites > Website List.
-
Click Edit next to your website name.
-
In the Preferences section, set the Scripting Templates for your site:
-
Scripting Template (Credit Card) – Select your customized Sales Order - Cash Sale form.
-
Scripting Template (Invoice) – Select your customized Sales Order - Invoice form.
-
-
To view execution logs, go to the script or the script deployment record, and click the Execution Log tab.