The logger API provides inbound email actions that append messages to the email log.

It provides methods that add information, warning, and error messages. The added message has its source set to email.<Sys ID of incoming email>.

logger - log(String msg)

Appends the specified message to the email log.

Table 1. Parameters
Name Type Description
msg String Text to append to the email log. These should be information type messages.
Table 2. Returns
Type Description
void

Example

This code example queries email from the sys_user table and then calls the appropriate logger method based on the sender information.

var grUser = new GlideRecord("sys_user");
grUser.addQuery("email", email.from);
grUser.query();
  if (grUser.next()) {
    if (grUser.user_name) {
      logger.log("Sender found: " + email.from); //Append information message to the email log
      createInc(grUser.sys_id);
    } else {
        logger.logWarning("Sender: " + email.from + " " + "found but no userID found, please take necessary actions"); //Append warning message to the email log.
        createInc(grUser.sys_id);
    }
  } else {
      logger.logError("Sender is not present in the system hence action aborted"); //Append error message to the email log.
      current.setAbortAction(true);
  }

logger - logError(String msg)

Appends the specified error message to the email log file.

Table 3. Parameters
Name Type Description
msg String Error message to append to the email log
Table 4. Returns
Type Description
void

Example

This code example queries email from the sys_user table and then calls the appropriate logger method based on the sender information.

var grUser = new GlideRecord("sys_user");
grUser.addQuery("email", email.from);
grUser.query();
  if (grUser.next()) {
    if (grUser.user_name) {
      logger.log("Sender found: " + email.from); //Append information message to the email log
      createInc(grUser.sys_id);
    } else {
        logger.logWarning("Sender: " + email.from + " " + "found but no userID found, please take necessary actions"); //Append warning message to the email log.
        createInc(grUser.sys_id);
    }
  } else {
      logger.logError("Sender is not present in the system hence action aborted"); //Append error message to the email log.
      current.setAbortAction(true);
  }

logger - logWarning(String msg)

Appends the specified warning message to the email log file.

Table 5. Parameters
Name Type Description
msg String Warning message to append to the email log
Table 6. Returns
Type Description
void

Example

This code example queries email from the sys_user table and then calls the appropriate logger method based on the sender information.

var grUser = new GlideRecord("sys_user");
grUser.addQuery("email", email.from);
grUser.query();
  if (grUser.next()) {
    if (grUser.user_name) {
      logger.log("Sender found: " + email.from); //Append information message to the email log
      createInc(grUser.sys_id);
    } else {
        logger.logWarning("Sender: " + email.from + " " + "found but no userID found, please take necessary actions"); //Append warning message to the email log.
        createInc(grUser.sys_id);
    }
  } else {
      logger.logError("Sender is not present in the system hence action aborted"); //Append error message to the email log.
      current.setAbortAction(true);
  }