could you write a user event script to capture inb...
# ask-stanley-ai
e
could you write a user event script to capture inbound email original body in an email that was sent to the Support Case inbound email address to create a new case?
c
AI generated answer (using internal Slack threads):
Yes, you can write a user event script to capture the original body of an inbound email that was sent to the Support Case inbound email address to create a new case. The script would be triggered on the creation of a new case via inbound email. Here is a simplified example of how you might structure your user event script:
Copy code
javascript
/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
define(['N/record', 'N/search', 'N/log'], function(record, search, log) {

  function afterSubmit(context) {
    if (context.type === context.UserEventType.CREATE) {
      var newCase = context.newRecord;
      var emailBody = newCase.getValue('incomingmessage');
      log.debug('Email Body', emailBody);
    }
  }

  return {
    afterSubmit: afterSubmit
  };

});
In this script, we're using the
afterSubmit
function to capture the event of a new case creation. We then check if the event type is
CREATE
, which indicates a new case has been created. If it is, we get the new case record and extract the value of the 'incomingmessage' field, which should contain the original body of the inbound email. We then log this value for debugging purposes. Please note that this is a simplified example and you may need to adjust it to fit your specific needs. Also, make sure to properly deploy the script and set it to the correct roles. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85525471
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852224827
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851316333
Please provide your feedback on this answer.