|
| 1 | +(function executeRule(current) { |
| 2 | + |
| 3 | + var _strCurrentTable = String(current.getTableName() || ''); |
| 4 | + var _strCurrentURL = String(gs.action.getGlideURI() || ''); |
| 5 | + |
| 6 | + if (_strCurrentTable.length === 0) { |
| 7 | + return; |
| 8 | + } |
| 9 | + |
| 10 | + //only continue with form views in the Classic UI |
| 11 | + if (!_strCurrentURL.startsWith(_strCurrentTable + '.do')) { |
| 12 | + return; |
| 13 | + } |
| 14 | + |
| 15 | + //determine the unique artifact ID |
| 16 | + var _strUpdateName = |
| 17 | + String( |
| 18 | + current.getValue('sys_update_name') || |
| 19 | + new GlideUpdateManager2().getUpdateName(current) || |
| 20 | + '' |
| 21 | + ); |
| 22 | + |
| 23 | + //Is this artifact tracked with versions? |
| 24 | + if (_strUpdateName.length > 0) { |
| 25 | + var _grUpdateXml = new GlideRecord('sys_update_xml'); |
| 26 | + |
| 27 | + //query all versions |
| 28 | + _grUpdateXml.addQuery('name', _strUpdateName); |
| 29 | + _grUpdateXml.orderByDesc('sys_updated_on'); |
| 30 | + _grUpdateXml.setLimit(1); |
| 31 | + _grUpdateXml.query(); |
| 32 | + |
| 33 | + //was the artifact changed and has a baseline version available? |
| 34 | + if (_grUpdateXml.next() && !_grUpdateXml.replace_on_upgrade) { |
| 35 | + var _isOOTB = false; |
| 36 | + var _grVersion = new GlideRecord('sys_update_version'); |
| 37 | + |
| 38 | + _grVersion.addQuery('name', _strUpdateName); |
| 39 | + _grVersion.orderByDesc('sys_recorded_at'); |
| 40 | + _grVersion.query(); |
| 41 | + |
| 42 | + //iterate the versions to check whether this is an OOTB artifact |
| 43 | + while (!_isOOTB && _grVersion.next()) { |
| 44 | + var _strSource = _grVersion.getValue('source_table') || ''; |
| 45 | + |
| 46 | + _isOOTB = _strSource === 'sys_upgrade_history' || _strSource === 'sys_store_app'; |
| 47 | + } |
| 48 | + |
| 49 | + if (_isOOTB) { |
| 50 | + gs.addErrorMessage( |
| 51 | + 'This OOTB artifact was changed and thus will create an skipped record during the next ' + |
| 52 | + 'upgrade!<br><br>In case the change was done accidentally, you should revert to the <a href="' + |
| 53 | + _grVersion.getLink(true) + '" target="_blank">most recent OOTB version.</a>' |
| 54 | + ); |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | +})(current); |
0 commit comments