Skip to main content
All CollectionsFAQ's
Creating Additional Scheduled Jobs
Creating Additional Scheduled Jobs

How to create additional scheduled jobs

B
Written by Blake Hester
Updated over a week ago
  1. Create a new Scheduled Job, making sure that it is in the VividCharts Application Scope.

  2. Paste the following script listed below into the script portion of the Scheduled Job.

  3. Script:

    1. // Config variables
      var view = "32999b0edb9bce50ee8ca09e13961981"; // The view to be refreshed
      var userDisplay = "System"; // The name that will appear under refresh info

      // Get the published slide deck sys_id for the view to be refreshed
      var sys_id = null;
      var viewGR = new GlideRecord("x_vivid_vc_core_view_slides_connection");
      if (viewGR.get("view", view)) {
      sys_id = viewGR.slides.published.toString();
      }

      // Only refresh if we got a slide deck sys_id
      if (sys_id) {
      var historyID = CollectionHistory.startCollection({
      "user": userDisplay,
      "userDisplay": userDisplay,
      "view": view
      });

      // create an event
      var asyncInputs = {
      sys_id: sys_id,
      target: null,
      userDisplay: userDisplay,
      historyID: historyID
      };

      // add a collection task to the queue
      var queueQuery = new GlideRecord("x_vivid_vc_core_queue_results");
      queueQuery.finished = false;
      queryID = queueQuery.insert();
      var queryInputs = JSON.stringify(asyncInputs);
      gs.eventQueue('x_vivid_vc_core.refresh_view', queueQuery, queryInputs);
      }
  4. Next, change the View sys_id located in line 2. You can locate the correct View sys_id from the x_vivid_vc_core_views table. Search for the view by title and copy the View sys_id.

  5. Paste the copied View sys_id into the var view = "32999b0edb9bce50ee8ca09e13961981"; portion of the code.

  6. You can create a new Scheduled Job for each view that you would like to refresh more than once daily.


    โ€‹


    โ€‹

Did this answer your question?