Workflow


Setting Up for Autotask

Adding a Button in Netsuite to Trigger a Work Order Create / Update


  • Add a new script by going to Customization->Script->New
  • Click on the + to upload a new file from computer
  • Click choose file and upload a script.

  • Add the following to the file:

function sendToFNOnClick()
{
    const response = nlapiRequestURL('<inbound_trigger_url>&external_id=' +  nlapiGetRecordId(),'', {});
    return true;
}
  • Replace with inbound trigger URL from the settings page:
  • Select Script Type “Client”

  • Click Create Script Record

  • Edit the script and add a button. Set the Label and Function. Function should match the function in script file.

  • Deploy the script by selecting which record to apply to. This is the record that will be used to create a work order in Field Nation.


Adding RESTlet to support file attachments

  • Upload script as in steps 1-4 of “Adding a Button in Netsuite to Trigger a Work Order Create / Update”

  • Select Script Type RESTLet

  • Click Create Script Record

  • Edit the script and set the POST Function StoreAttachFile

  • Deploy the script and look for the External URL
  • Use the External URL in settings in order to upload file

  • Change the script from Testing to Release if trying to run this from a user token that is not the same as the user uploading the script. Testing restricts script permission to the owner of the script.

  • Make sure the Role for the user has List → Documents and Files of at least “Create”


Adding a User Event in Netsuite to Trigger an Inbound Message Create

  • Add a new script by going to Customization->Script->New

  • Click on the + icon beside the SCRIPT FILE field to upload a new file from the computer

  • Click the select file and upload a script.

  • File content should be like below. Replace with inbound trigger URL from the settings page.

function beforeSubmit(type) {
  nlapiLogExecution("DEBUG", "Before Submit", "action=" + type);
}

function afterSubmit(type) {
  var message_id = nlapiGetRecordId();
  var message = nlapiGetNewRecord();
  var record_id = message.getFieldValue("transaction");
  nlapiLogExecution("DEBUG", "After Submit", "action=" + type + ", id="+ message_id + ", transaction=" + record_id);
  if (message_id && record_id) {
    const response = nlapiRequestURL('<inbound_trigger_url>&external_id=' + record_id + '&message_id=' + message_id, '', {});
  }
  return true;
}
  • Select Script Type User Event.

  • Click Create Script Record.

  • Edit the script and add the function name. The function name should match the function in the script file.

  • Deploy the script by selecting which record to apply to. This is the record that will be used to add a message in Field Nation.