Create a multi-table processor

  • Rversion finale: Australia
  • Mis à jour 12 mars 2026
  • 1 minute de lecture
  • Create a multi-table processor that reports the number of rows in any table on your instance. This feature is deprecated.

    Avant de commencer

    Role required: admin

    Pourquoi et quand exécuter cette tâche

    Remarque :
    This feature is deprecated. While legacy, existing custom processors continue to be supported, creating new custom processors has been deprecated. Instead, use the Scripted REST APIs

    The multi-table processor protects itself from performance and security violations by confirming that the user is authorized to read the table. It does not report on certain tables that are too large to query safely.

    Procédure

    1. Navigate to All > System Definition > Processors.
      The list of processors appears.
    2. SelectNew.
    3. Enter the following information.
      Name TableSize
      Type Choose Javascript
      Description Return number of records in a table
      Parameters SIZE
      Path <leave empty>

      Script:

      g_response.setContentType('text/html;charset=UTF-8');
      if(g_target === 'sys_email' || g_target === 'sys_log' ) 
      {
        g_processor.writeOutput(g_target + ' table is too large to quickly count');
        } else {   
          var count = new GlideAggregate(g_target);
          if( count.canRead() ) {
            count.addAggregate('COUNT');
            count.query();
            var records = 0;
            if (count.next()) {
              records = count.getAggregate('COUNT');
             }
             g_processor.writeOutput('table ' + g_target + ' has ' + records + ' records');
            } else {
             g_processor.writeOutput('You do not have access to table ' + g_target);
        }
      }            
    4. Select Save.
    5. Test the new processor by entering the following URLs:
      https://<instancename>.service-now.com/incident.do?SIZE and https://<instancename>.service-now.com/sys_user.do?SIZE
      Your instance reports the number of records in the table. For example, table incident has 82 records.