Loading
Slack 관련 문의처가 Salesforce Help로 통합 및 변경됩니다.더 많이 읽기
판매 협약 대량 업데이트에 대한 오류 레코드 관리

판매 협약 대량 업데이트에 대한 오류 레코드 관리

판매 협약 대량 업데이트가 처리되지 않을 경우 정확한 실패 세부 사항이 포함된 시스템 로그가 기본 배치 관리 프레임워크 내에 저장됩니다. 그러나 BatchJobPart 엔티티의 RecordFile 필드에 대한 직접 액세스는 기본적으로 제한되어 있으므로 관리자와 사용자가 기본적으로 이러한 실패 세부 사항을 볼 수 없습니다. 다음 방법에 따라 추적 가시성을 복원하고 사용자가 실패한 레코드의 문제를 해결하는 데 도움이 되는 사용자 정의 구성 요소 및 액세스 경로를 구성합니다.

필수 Edition

지원 제품: Lightning Experience
지원 제품: Enterprise, Unlimited 및 Developer Edition

옵션 1: 레코드 페이지를 통해 직접 파일 데이터에 액세스(권장)

이 접근 방식을 사용하면 관리자가 Apex 서비스 및 Aura 구성 요소를 구축하여 비즈니스 사용자가 Lightning UI에서 직접 대량 업데이트 오류를 가져오고 검토할 수 있습니다.

  1. Developer Console에서 Apex 서비스 클래스를 만듭니다.
    1. Developer Console을 엽니다.
    2. Developer Console에서 다음 Apex 클래스를 만들어 파일 데이터를 직접 가져옵니다.
      public class BatchJobService {
          @AuraEnabled(cacheable=false)
          public static String getBatchJobParts(String batchJobPartId) {
              try {
                  // Query the targeted BatchJobPart record
                  BatchJobPart record = [
                      SELECT RecordFileBody, RecordFileName 
                      FROM BatchJobPart 
                      WHERE Id = :batchJobPartId 
                      LIMIT 1
                  ];
                  
                  // Decode the Blob into a readable UTF-8 String
                  Blob decodedBlob = record.RecordFileBody;
                  String fileData = decodedBlob != null ? decodedBlob.toString() :
       'No file data found.';
                  
                  System.debug(fileData);
                  return fileData;
              } catch (Exception e) {
                  return 'Error: ' + e.getMessage();
              }
          }
      }

      클래스가 원활하게 실행되는지 확인하려면 디버그 > 익명 실행 창 열기 를 열고 다음 코드를 실행합니다. 파일 데이터를 쿼리할 관련 BatchJob의 batchJobPartID()로 입력을 교체합니다.

      배치 작업 부품 세부 사항

      BatchJobService.getBatchJobParts('0mexx000000003IAAQ');

      아래와 같이 디버그 로그에서 출력을 볼 수 있습니다.

      배치 작업 출력

  2. Aura 구성 요소 만들기
    새 구성 요소 만들기(이름: FileDataViewer) - 사용자에게 데이터를 표시합니다. 이렇게 하면 오른쪽 패널에 표준 파일이 표시됩니다(파란색). 구성 요소 구성에서 Lightning 레코드 페이지에만 사용 가능으로 표시합니다(아래 스크린샷에 표시됨).

    새 구성 요소 추가구성 요소 구성

    1. Developer Console에서 이름이 FileDataViewer인 새 Aura 구성 요소 번들을 만듭니다.
      <aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" 
                      controller="BatchJobService" 
                      access="global">
          
          <aura:attribute name="recordId" type="Id" />
          <aura:attribute name="result" type="String" />
          <aura:attribute name="error" type="String" />
          
          <lightning:card title="" class="slds-m-around_medium">
              <div class="slds-m-bottom_medium">
                  <lightning:button label="Fetch File Data" 
                                    onclick="{!c.handleClick}" 
                                    variant="brand" />
                  <lightning:button label="Download as .txt" 
                                    onclick="{!c.downloadFile}" 
                                    variant="neutral" 
                                    class="slds-m-left_small" 
                                    disabled="{!empty(v.result)}" />
              </div>
              
              <aura:if isTrue="{!not(empty(v.result))}">
                  <div class="slds-box slds-box_xx-small slds-theme_default slds-scrollable_y" 
                       style="max-height: 300px;">
                      <pre>{!v.result}</pre>
                  </div>
              </aura:if>
              
              <aura:if isTrue="{!v.error}">
                  <div class="slds-text-color_error slds-m-top_medium">
                      {!v.error}
                  </div>
              </aura:if>
          </lightning:card>
      </aura:component>

      다음과 같이 도우미 파일을 만듭니다.

      ({
          handleClick: function(component, event, helper) {
              var action = component.get("c.getBatchJobParts");
              action.setParams({ batchJobPartId: component.get("v.recordId") });
              
              action.setCallback(this, function(response) {
                  var state = response.getState();
                  if (state === "SUCCESS") {
                      component.set("v.result", response.getReturnValue());
                      component.set("v.error", null);
                  } else {
                      var errors = response.getError();
                      component.set("v.error", errors && errors[0] ? 
      errors[0].message : "Unknown error");
                  }
              });
              $A.enqueueAction(action);
          },
          
          downloadFile: function(component, event, helper) {
              var data = component.get("v.result");
              var element = document.createElement('a');
              var file = new Blob([data], { type: 'text/plain' });
              
              element.href = URL.createObjectURL(file);
              element.download = 'BatchJobPart.txt';
              document.body.appendChild(element);
              element.click();
              document.body.removeChild(element);
          }
      })
  3. 배치 작업 부분의 레코드 페이지에 새 구성 요소 첨부
    1. 배치 작업 부품 세부 사항 레코드 페이지로 이동합니다.
    2. 기어 아이콘을 클릭하고 페이지 편집을 선택하여 Lightning 앱 빌더를 엽니다.
    3. 사용자 정의 FileDataViewer 구성 요소를 기본 페이지 캔버스 레이아웃으로 끌어옵니다.
    4. 업데이트된 Lightning 레이아웃 페이지를 저장하고 활성화합니다.
  4. 로그 데이터 보기 및 추출
    1. 대상 레코드 페이지로 이동합니다.
    2. 파일 데이터 가져오기를 클릭하여 파일 내용을 미리 보고 화면에서 오류를 인라인으로 확인합니다.
    3. .txt로 다운로드를 클릭하여 필터링 및 기록 감사를 위해 로컬 파일 시스템에 텍스트 오류 로그를 저장합니다.

옵션 2: 워크벤치를 통해 로그 데이터에 액세스(관리자 전용)

사용자 정의 구성 요소 레이아웃을 배포하지 않고 즉시 확인해야 하는 경우 관리자는 Salesforce 워크벤치를 통해 직접 특별히 RecordFile 페이로드를 추출할 수 있습니다.

  1. 환경의 워크벤치 인스턴스에 로그인합니다.
  2. 유틸리티 탭으로 이동하여 Apex 실행 패널을 엽니다.
  3. 아래에 명시된 코드를 사용합니다(ID를 실제 배치 작업 부분 엔티티 ID로 바꾸십시오).
    try {
        BatchJobPart record = [
            SELECT RecordFileBody, RecordFileName 
            FROM BatchJobPart 
            WHERE Id = '0meXR0000000EZFYA2' 
            LIMIT 1
        ];
        
        Blob decodedBlob = record.RecordFileBody;
        String fileData = decodedBlob != null ? decodedBlob.toString() 
    : 'No file data found.';
        System.debug('Decoded File Data: ' + fileData);
    } catch (Exception e) {
        System.debug('Error: ' + e.getMessage());
    }
  4. 실행을 클릭합니다.
  5. 출력에서 USER DEBUG 태그를 통해 처리된 출력 텍스트를 직접 검토합니다.

    배치 작업 부분 레코드 페이지에서 데이터 보기

 
로드 중
Salesforce Help | Article