Apex
-
[apex] 두 날짜 간의 차이 계산 방법 ( How to calculate the difference between two dates)Apex 2024. 8. 17. 21:49
1. 예시 코드 확인Date ExcutionStartDate = Date.newInstance(2024, 8, 1);Date ExcutionEndDate = Date.newInstance(2024, 8, 17);if (ExcutionStartDate != null && ExcutionEndDate != null) { // 두 날짜 사이의 일 수 차이 계산 Integer daysDifference = ExcutionStartDate.daysBetween(ExcutionEndDate) + 1; // 주 단위와 일 단위 계산 Integer ExcutionWeek = Math.floor(daysDifference / 7); Integer ExcutionDay = Math.mod..
-
[Apex] 선택목록 필드의 option 값 가져오는 방법 - How to get option value of selection list fieldApex 2024. 8. 17. 21:17
1. 순서 및 로직 개체 가져오기Schema.getGlobalDescribe().get(개체명).getDescribe();return Schema.DescribeSObjectResult개체의 필드 가져오기개체명.fields.getMap().get(필드명).getDescribe();return Schema.DexcribeFieldResult필드의 option 값 가져오기필드명.getPicklistVales();return List필드 option 값 사용하기 ( Label 및 Vale)Schema.PicklistEntry.getLabel();Schema.PicklistEntry.getValue();return String 2. 예시 코드 확인 2-1 : 기본 코드 형식String obj = '값 가져올 ..
-
Apex Tests Api 모의 응답(Mock) 생성 - implement HttpCalloutMockApex 2024. 4. 27. 21:35
1. implements HttpCalloutMock ( 모의 응답 Class 생성 )@isTestimplements HttpCalloutMockglobal HttpResponse respond(){ ... } @isTestglobal class zz_Clvs_MDE_Test_ResponseDocumentCancel implements HttpCalloutMock{ global HttpResponse respond(HttpRequest request){ System.debug('@@@@ 문서 서명요청취소 Response 생성 @@@@ ' + request); Integer resStatusCode = 201; String resBody = '{..
-
Apex Tests Api 모의 응답(Mock) 생성 - StaticResorceApex 2024. 4. 16. 16:17
1. StaticResourceCalloutMock 이란?HTTP 콜아웃 테스트를 위한 가짜 응답을 지정하는 데 사용되는 유틸리티 클래스메서드 - setHeader(), setStaticResource(), setStatus(), setStatusCode()관련 help 문서2. 대상 org에 정적자원 등록콜아웃 테스트를 위한 가짜 API 응답값 등록 ( 파일 확장자명 .json 으로 변경하여 등록 )파일 내용{ "id": "2314fa20-fb8a-11ee-ad0a-775297304a05", "expiry": "2024-04-16T02:42:00.770Z", "embeddedUrl": "https://app.modusign.co.kr/embedde..
-
apex 숫자 원화 표시하는 방법 - ( apex How to display numbers ₩0,000,000 )Apex 2024. 4. 5. 16:00
1. setScale(0).format(); 숫자 -> 원화표시 10000000 -> ₩ 10,000,000 Decimal numberA = 10000000; String stringA = '₩' + numberA.setScale(0).format(); 2. Decimal.valueOf([원화형식StringValue].replaceAll(...)); 원화 -> 숫자표시 ₩ 10,000,000 -> 10000000 String stringA = '₩10,000,000'; Decimal numberA = Decimal.valueOf(stringA.replaceAll('[^0-9]', '')); 3. 예시 코드 원화표시된 기존 금액 ₩ 10,000,000에 청구금액(BillingAmount__c)을 더하여 원..
-
apex 및 JS에서 리스트 중복제거 ( apex JS - Remove duplicates from list )Apex 2024. 3. 15. 22:16
Apex에서 리스트 중복 제거 Set 을 이용한 방법 List targetList = new List{'A', 'B', 'C', 'B', 'B', 'D', 'A', 'C'}; Set setStr = new Set(); for(String str : targetList){ setStr.add(str); } System.debug(setStr); // DEBUG|(A, B, C, D) 출력 Map을 이용한 방법 List targetList = new List{'A', 'B', 'C', 'B', 'B', 'D', 'A', 'C'}; //( 마지막에 중복된 값으로 최종 저장됨 1.2...99 이면 99로 저장됨 ) Map targetMap = new Map(); for (String str : targetLis..
-
String을 DateTime으로 파싱 ( Parse String into dateTime )Apex 2024. 3. 7. 23:05
1. ISO 8601 형식으로 표현된 날짜와 시간 String String createDate = '2024-02-29T02:27:56.000Z'; "2024-02-29": 날짜 (년-월-일) "T": 날짜와 시간을 구분하는 구분자 "02:27:56.000": 시간 (시:분:초.밀리초) "Z": UTC(협정 세계 시)를 나타내는 시간대 표시 2. 'T'와 'Z'를 제거 후 Datetime.valueOf(String) String toConvert = '2024-02-29T02:27:56.000Z'; toConvert = toConvert.replace('T', ' ').replace('Z', ''); Datetime actualDatetime = Datetime.valueOf(toConvert); Sys..