2 Replies · Latest reply on Apr 21, 2017 4:31 AM by Zsolt Mester

    List of available names of current.request.requested_for ?

      Hello everyone,

       

      I am in training to use ServiceNow to create workflows.

      I only have limited access - department admin role - I cannot view any tables or their attributes, so I am trying to explore what attributes can I reference inside my workflow scripts, by creating a dummy catalog item and workflow and logging the results in the workflow context.

       

      So far I have succeeded in listing the available attributes by specifying a table name and passing it to a function.

       

      function getTableObject(table_name) {
          return new GlideRecord("sys_db_object").get("name", table_name);
      }
      
      function getParentTables(table_name, tables) {
          var table_obj = getTableObject(table_name);
          var parent_table = table_obj.super_class;
      
          while (parent_table) {
              tables.push(parent_table);
              parent_table = parent_table.super_class;
          }
          return tables;
      }
      
      function getTableFields(tables) {
          var fields = new GlideRecord("sys_dictionary");
      
          for (var i = 0; i < tables.length; i++) {
              fields.addQuery("name", tables[i]);
          }
          fields.query();
          return fields;
      }
      
      function listTableAttributes(table_name) {
          var tables = [];
          tables.push(table_name);
      
          tables = getParentTables(table_name, tables);
          fields = getTableFields(tables);
      
          while (fields.next()) {
              workflow.info(fields.element);
          }
      }
      

       

      So if I want to check the list of available attributes for "current.request", I would run this code with listTableAttributes("sc_request")

       

      My question is, how can you do the same if I want to go a level deeper and list the available attributes for "current.request.requested_for" or any other attribute of "current.request"?

       

      Thank you for your help,