Name

global.UpgradeHistoryLogPriority

Description

This will populate priority for sys_app_file_type based on the priority of fields in sys_dictionary

Script

var UpgradeHistoryLogPriority = Class.create();
UpgradeHistoryLogPriority.prototype = {
  initialize: function() {},
  
  generate : function(type, priority) {
  	// prevent transaction cancellation by quota rules
  	var t = null;
  	var isUncancelable = false;
  	try {
  		t = GlideTransaction.get();
  		if (t != null) {
  			isUncancelable = t.isUncancelable();
  			t.setCannotCancel(true);
  		}
  
  		var gr = new GlideRecord('sys_dictionary');
  		gr.addQuery('internal_type', '=', type);
  		gr.query();
  		while(gr.next()) {
  			var tableName = gr.getValue('name');
  			if (tableName !== null)
  				this.setTablePriority(tableName, priority);
  		}
  	} finally {
  		if (t != null)
  			t.setCannotCancel(isUncancelable);
  	}
  },
  
  setTablePriority : function(tableName, priority) { 
  	var appFile = new GlideRecord('sys_app_file_type');
  	appFile.addQuery('sys_source_table', tableName);
  	appFile.query();
  	if (appFile.next()) {
  		appFile.setValue('priority', priority);
  		appFile.update();
  		gs.print("Updating table '" + tableName + "' with priority '"+priority+"'");
  	}
  }, 

  type: 'UpgradeHistoryLogPriority'
};

Sys ID

0f43a330c3333100f25d174292d3ae07

Offical Documentation

Official Docs: