Name

global.ScrumPlanningBoardAjaxProcessor

Description

ScrumPlanningBoardAjaxProcessor - Provides methods for AJAX functionality of the planning board

Script

/**
* ScrumPlanningBoardAjaxProcessor
* Provides methods for AJAX functionality of the planning board
*
* @Author Chris Henson <chris.henson@service-now.com>
*/
var ScrumPlanningBoardAjaxProcessor = Class.create();

ScrumPlanningBoardAjaxProcessor.prototype = Object.extendsObject(AbstractAjaxProcessor,{
  /* initialize(request, responseXML, gc): Overidden method from the parent class
   *
   * Calls the super initialize method and then sets up loging.
   */
  initialize : function(request, responseXML, gc, _gs) {
      AbstractAjaxProcessor.prototype.initialize.call(this,request, responseXML, gc);
      this._log=(new GSLog("com.snc.sdlc.scrum.pp.log",this.type)).setLog4J();
      //this._log.setLevel(GSLog.DEBUG);

      // Default this._gs to the global if one isn't passed in.
      this._gs = (JSUtil.notNil(_gs) ? _gs : gs);
  },

  /**
   * saveuserPref(): Saves a planning user view preference
   *
   * This methods expects the following parameters to be set in the params object:
   *   1. _tn     : The name of the table
   *   2. _sysId  : The relevant sys id
   *   3. paneName: The name of the pane that's having it's preference saved
   */
  saveUserPref: function() {
      // Set up the AJAX return
      var r = this.newItem();
      var params = this._getParams(r);

      if (this._log.atLevel(GSLog.DEBUG)) {
          this._log.debug("[setUserPref]  pref: com.snc.sdlc.scrum.pp.planning."+params.paneName+"_parent");
          this._log.debug("[setUserPref] value: " + params._tn+":"+params._sysId+":true");
      }

      this._gs.getUser().setPreference("com.snc.sdlc.scrum.pp.planning."+params.paneName+"_parent",params._tn+":"+params._sysId+":true");
      r.setAttribute("result","success");
  },

  /**
   * _getParams(r): Internal method used to get the parameters
   *
   * r: The retrun values for the AJAX request
   *
   * 1. This method will check that the following parameters have been set:
   *    1.1 _tn         : Table name
   *    1.2 _sys_id     : The sys_id of the record
   *    1.3 pane_name   : The name of the pane in the planning board
   */
  _getParams: function(r) {
      var params = {}; //Set up a simple nvp object for parameters
      // Required fields
      params._tn = this._getParam("_tn");
      params._sysId = this._getParam("_sys_id");
      params.paneName = this._getParam("pane_name");

      if (this._log.atLevel(GSLog.DEBUG)) { 
          this._log.debug("[_getParams] Data Received:");
          this._log.debug("[_getParams]      _tn: " + params._tn);
          this._log.debug("[_getParams]   _sysId: " + params._sysId);
          this._log.debug("[_getParams] paneName: " + params.paneName);
      }

      // If we don't have any data for the parent record.
      if (JSUtil.nil(params._tn) || JSUtil.nil(params._sysId)) {
          r.setAttribute("result","failure");
          r.setAttribute("reason","The record's Sys Id and table name are required");
      this._log.error("[_getParams] Sys Id and table name are required");
          return null;
      }

      return params;
  },

  /* _getParam(prmNm): Gets the parameter named prmNm, checks for spurious undefined and null values and
   *                   returns a string representation.  Returns null if undefined.
   */
  _getParam: function(prmNm) {
      var param = this.getParameter(prmNm)+"";

      if (typeof param === "undefined" || param == "undefined" || param == "null" || param == null || JSUtil.isNil(param))
          return null;

      return param;
  },
  
  /**
   * Prevent public access to this processor
   */
  isPublic: function() {
  	return false;
  },

  type: "ScrumPlanningBoardAjaxProcessor"
});

Sys ID

903c7d13c30130003d2ae219cdba8f7f

Offical Documentation

Official Docs: