修復スクリプトを実行して、サービスの小数点以下桁数を有効にします

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:3分
  • Yokohama パッチ 12 または Zurich パッチ 6 にアップグレードした後、サービスの小数点以下桁数を指定できない場合は、バックグラウンド修正スクリプトを実行して小数点以下桁数のサポートを有効にする必要があります。

    始める前に

    必要なロール:sn_shop.procurement_administrator

    このタスクについて

    Yokohama パッチ 12 または Zurich パッチ 6 にアップグレードしても、サービスの小数点以下桁数を指定できない場合は、[スクリプト - バックグラウンド] モジュールからこのスクリプトを実行します。スクリプトは、数量フィールドタイプを整数から小数に変換し、フィールドスケールを小数点以下 4 桁に更新します。

    手順

    1. 移動先 すべて > システム定義 > スクリプト - バックグラウンド.
    2. [ スクリプトを実行 (サーバーで実行される JavaScript )] セクションに、次のコードを貼り付けます。
      (function() {
         var tableName = 'sn_spend_sdc_service_request_line';
         var columnName = 'new_purchased_quantity';
         if (pm.isZboot()) {
             return;
         }
         try {
             var updated = GlideFixStuff.fixTypeFromIntegerToDecimalCaseLineQuantityItem(tableName, columnName);
             if (!updated) {
                 gs.info('Cannot update type from integer to decimal for field ' + columnName);
                 return;
             }
             updateScale();
         } catch (ex) {
             gs.info('Cannot update type from integer to decimal with error ' + JSON.stringify(ex));
             return;
         }
         function updateScale() {
             var desiredScale = 4;
             var dictGR = new GlideRecord('sys_dictionary');
             var query = 'name=' + tableName + '^elementIN' + columnName;
             var fieldName;
             dictGR.addEncodedQuery(query);
             dictGR.query();
             if (dictGR.next()) {
                 try {
                     var attrbiuteArray = [];
                     var currentAttributes = dictGR.attributes;
                     if (currentAttributes != '') {
                         attrbiuteArray = currentAttributes.split(',');
                     }
                     var currentMaxLength = dictGR.max_length;
                     fieldName = dictGR.element;
                     var newMaxLength = currentMaxLength + desiredScale;
                     dictGR.max_length = newMaxLength;
                     attrbiuteArray.push("scale=" + desiredScale);
                     dictGR.attributes = attrbiuteArray.join(',');
                     dictGR.update();
                     dictGR.max_length = newMaxLength + 1;
                     dictGR.update();
                     gs.info('Updated max length twice for field ' + fieldName);
                 } catch (ex) {
                     gs.info('Cannot update scale attribute due to error : ' + JSON.stringify(ex));
                     gs.error('Error updating max length attribute for field {0}. No update performed.', fieldName);
                 }
             }
         }
      })();
    3. [ ロールバックするレコード?] チェックボックスの選択を解除します。
    4. [スクリプトの実行] を選択します。