[Technical terms]リアクティブプロパティ

リアクティブプロパティとは、値が変更されたときに、変更を検知して自動的にUIを更新するような、プロパティのことです。具体的には、変更を監視し、変更があった場合に、自動的に関連するUIを更新するための仕組みを指します。

例:

  • Vue.jsでは、データが変更されると、自動的にHTMLに反映されます。これは、Vue.jsのリアクティブシステムによるものです。

[SalesforceDeveloperCertification]認定 Platform デベロッパー資格の更新 (Winter ’25)

public class MyIterable implements Iterable<String> {
    private List<String> strings {get; set;}

    public MyIterable(List<String> strings) {
        this.strings = strings;
    }

    public Iterator<String> iterator() {
       return this.strings.iterator();
    }
}

@IsTest
private class MyIterableTest {
    
    @IsTest static void testIterableForLoop() {
        
            List<String> strings = new List<String>{'Hello','World'};
                
            MyIterable mi = new MyIterable(strings);

            Test.startTest();
            
            for (String str : mi) {
                System.debug(str);
            }

            Test.stopTest();
    }
}

[Salesforce]Failed to run tests synchronously.: Your query request was running for too long.

테스트 클래스 실행 시 “Failed to run tests synchronously.: Your query request was running for too long.” 오류 대응

Summary
Test classes failing with QUERY_TIMEOUT Failed to run tests synchronously when running in synchronous mode

Login to the org which has quite number of managed package apex classes.
Run the Apex Test Class from Developer Console in Sync Mode
You may notice below exception when running the apex test class:
Error Message:

“QUERY_TIMEOUT Failed to run tests synchronously: Your query request was running for too long”

Workaround
As a workaround, please try to run the test class in asynchronous mode.

[Salesforce]Failed to run tests synchronously.: Your query request was running for too long.

Handling the error “Failed to run tests synchronously.: Your query request was running for too long.” when running a test class

Summary
Test classes failing with QUERY_TIMEOUT Failed to run tests synchronously when running in synchronous mode

Login to the org which has quite number of managed package apex classes.
Run the Apex Test Class from Developer Console in Sync Mode
You may notice below exception when running the apex test class:
Error Message:

“QUERY_TIMEOUT Failed to run tests synchronously: Your query request was running for too long”

Workaround
As a workaround, please try to run the test class in asynchronous mode.

[Salesforce] SOQL 문의 HAVING 사용법

SOQL 문의 HAVING

HAVING에서는 GROUP BY로 그룹화한 결과에 대해 좁혀 조건을 넣을 수 있습니다.

좁힌 조건이라는 의미에서는 WHERE와 비슷하지만, WHERE에서는 그룹핑하기 전, HAVING은 그룹핑한 후입니다.

다음 샘플은 기회의 리드 소스로 그룹화하고 동일한 값의 레코드 수가 1 이상인 리드 소스별 금액을 표시합니다.

AggregateResult[] results = [SELECT LeadSource, SUM(Amount) summary 
                               FROM Opportunity 
                               GROUP BY LeadSource 
                               HAVING Count(LeadSource) > 1];
for(AggregateResult ar: results){
  System.debug('LeadSource='+ ar.get('LeadSource') 
                   + ':Amount='+ ar.get('summary'));
}

디버그 결과

LeadSource=LeadSource1:Amount=2
LeadSource=LeadSource2:Amount=3

[Salesforce] How to use HAVING in SOQL statements

SOQL statement HAVING

HAVING allows you to enter filtering conditions for the results grouped by GROUP BY.

It is similar to WHERE in that it is a filtering condition, but WHERE is before grouping and HAVING is after grouping.

The following sample groups by the lead source of the opportunity and displays the amount by lead source where the number of records with the same value is 1 or more.

AggregateResult[] results = [SELECT LeadSource, SUM(Amount) summary 
                               FROM Opportunity 
                               GROUP BY LeadSource 
                               HAVING Count(LeadSource) > 1];
for(AggregateResult ar: results){
  System.debug('LeadSource='+ ar.get('LeadSource') 
                   + ':Amount='+ ar.get('summary'));
}

Debugging Results

LeadSource=LeadSource1:Amount=2
LeadSource=LeadSource2:Amount=3