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.

  1. Go to Customization > Forms > Transaction Forms.

    1. 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.

    2. After you create the two new forms, make a note of their Internal IDs.

  2. 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.

  3. Create a new client script, and then deploy it for all sales order forms.

    1. Go to Customization > Scripting > Scripts > New > Client Script.

    2. Enter event functions, and attach any library scripts.

    3. On the Deployments subtab, in the Applies to column, select Sales Orders.

    4. Click Save & Deploy.

    5. On the Audience subtab of the script deployment record, make sure that Customer Center is selected.

  4. Select the newly created sales order forms as the Scriptable Template for your web store.

    1. Go to Commerce > Websites > Website List.

    2. Click Edit next to your website name.

    3. 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.

Related Topics

Testing Scriptable Cart
Resolving Permission Errors in Scriptable Cart
Debugging Your Shopping Cart Scripts Using Firebug
Deploying and Running Scriptable Cart

General Notices