Name

sn_sow_req.RequestedItemInfoSNC

Description

No description available

Script

var RequestedItemInfoSNC = Class.create();
RequestedItemInfoSNC.prototype = {
  initialize: function(gr) {
  	this._gr = gr;
  	this._catalogSOWUtil = new sn_sow_req.CatalogSOWUtils();
  },
  getPriceDisplayValue : function() {
  	var priceDisplayValue = '';
  	var price = this._gr.getValue("price");
  	var recurringPrice = this._gr.getValue("recurring_price");
  	var recurringFreq = this._gr.getValue("recurring_frequency");
  	var showPrice = this._catalogSOWUtil.showPrice(price);
  	var showRecurringPrice = global.JSUtil.notNil(recurringFreq) && this._catalogSOWUtil.showPrice(recurringPrice);
  	if (!showPrice && !showRecurringPrice)
  		return priceDisplayValue;
  	
  	priceDisplayValue += "<div>";
  	if (showPrice && showRecurringPrice)
  		priceDisplayValue += "&nbsp;&nbsp;&nbsp";
  	if (showPrice)
  		priceDisplayValue += this._gr.getDisplayValue("price");
  	if (showPrice && showRecurringPrice)
  		priceDisplayValue += "<br>+ ";
  	if (showRecurringPrice)
  		priceDisplayValue += this._gr.getDisplayValue("recurring_price") + " " + this._gr.getDisplayValue("recurring_frequency");
  	priceDisplayValue += "</div>";
  	return priceDisplayValue;
  },
  getDisplayValueBasedOnFieldType : function(field) {
  	if (field == "price")
  		return this.getPriceDisplayValue();
  	return this._gr.getDisplayValue(field);
  },
  getRenderTypeBasedOnFieldType : function(field) {
  	if (field == "price")
  		return "html";
  	return "string";
  },
  getHeaderInfo : function() {
  	var result = {};
      result.mainHeading = gs.getMessage('Record Information');
      var userGr = new GlideRecord('sys_user');
      userGr.addActiveQuery();
      userGr.addQuery("user_name", this._gr.getDisplayValue('sys_updated_by'));
      userGr.query();
      if (userGr.next() && userGr.getValue('name'))
          result.updateMsg = gs.getMessage("Last updated by {0}", userGr.getValue('name'));
      else
          result.updateMsg = gs.getMessage("Last updated by {0}", this._gr.getDisplayValue('sys_updated_by'));
      result.updatedTime = this._gr.sys_updated_on.getDisplayValue();
      return result;
  },
  getFieldsInfo : function() {
  	//the fields we need are state, price, quantity, and due_date		
  	var fields = ['state', 'price', 'quantity', 'due_date'];
  	var result = [];
  	for (var i = 0; i < fields.length; i++) {
  		var fieldDisplayValue = this.getDisplayValueBasedOnFieldType(fields[i]);
  		if (global.JSUtil.nil(fieldDisplayValue))
  			continue;
  		result.push({
  			label : this._gr[fields[i]].getLabel(),
  			value : {
  				type :  this.getRenderTypeBasedOnFieldType(fields[i]),
  				value : fieldDisplayValue
  			}
  		});
  	}
  	return result;
  },
  getRequestedForInfo: function() {
  	if (!this._gr.requested_for)
  		return "";
  	return this._catalogSOWUtil.getRequestedUserInfo(this._gr.requested_for.getRefRecord());	
  },
  getSourceInfo : function() {
  	var result = {
  		requestorInfo : this.getRequestedForInfo(),
  		sourceHeading : gs.getMessage('Requested for'),
  		name : this._gr.getDisplayValue('requested_for'),
  		assigneeDetails : [{
  			label : this._gr['opened_by'].getLabel(),
  			value : {
  				type : "string",
  				value : this._gr.getDisplayValue('opened_by')
  			}
  		}]
  	};
  	return result;
  },
  getRecordInfo : function() {
  	var result = {};
  	result.headerInfo = this.getHeaderInfo();
  	result.fieldsInfo = this.getFieldsInfo();
  	result.sourceInfo = this.getSourceInfo();
  	return result;
  },
  type: 'RequestedItemInfoSNC'
};

Sys ID

b978c8d745373010f877bf745626378b

Offical Documentation

Official Docs: