[Firebase]auth/admin-restricted-operation This operation is restricted to administrators only.エラー対応

Firebaseで認証時に以下のエラーの対応

auth/admin-restricted-operation This operation is restricted to administrators only.

Firebaseのコンソール画面 >   Authentication >  Sign-in method  > 利用したい認証方式有効

[Salesforce]Apex コントローラでの内部クラスの使用

Apex コントローラでの内部クラスの使用

public with sharing class SampleController {

    //Sample用
    public SampleSetting Sample {get;set;}

    // コンストラクタ
    public SampleController(){
        //初期処理
        init();
    }

    //初期処理
    private void init(){
        //Sample
        SampleSet();
    }


    //Sample
    private void SampleSet(){

        // カスタム[SampleSetting]から情報取得
        SampleSetting__c mc = SampleSetting__c.getOrgDefaults();
        mc = SampleSetting__c.getOrgDefaults();

        this.Sample =  new SampleSetting();
        this.Sample.Sample_Key = mc.Sample_Key__c;
    }

    //Sampleクラス
    public class SampleSetting {

        public String Sample_Key {get;set;}

        public SampleSetting(){
            this.Sample_Key = '';
        }
            
    }

}

[Salesforce]Apexトリガのアップデートの前後の値の比較

Apexトリガのアップデートの前後の値の比較

trigger UpdateProductObjTrigger on ProductObj__c (before update) {
    for(ProductObj__c productObj : Trigger.New) {
        ProductObj__c oldProductObj = Trigger.oldMap.get(productObj.id);
        if (productObj.Status__c != oldProductObj.Status__c ) {
            productObj.Is_Updated__c = true;
        }
    }
}

[Salesforce]Apexバッチで集計関数

Apexバッチで集計関数

//バッチクラス
global class SampleAggregateBatch implements Database.Batchable<AggregateResult> {
  // The batch job starts
  global Iterable<AggregateResult> start(Database.BatchableContext bc){
    String query = 'SELECT COUNT(Id) cnt, AccountId FROM Contact GROUP BY AccountId';
    return new SearchResultIterable(query);
  } 
  // The batch job executes and operates on one batch of records
  global void execute(Database.BatchableContext bc, List<sObject> scope){ 
    for(sObject sObj : scope) {
      AggregateResult ar = (AggregateResult)sObj;
      System.debug('>>>> COUNT : ' + ar.get('cnt'));
    }
  }
  // The batch job finishes
  global void finish(Database.BatchableContext bc){ }
}

//インタフェースIterable Apex class
public class SearchResultIterable implements Iterable<AggregateResult>{
	private String query;

    public SearchResultIterable(String soql){
    	this.query = soql;
  	}

    public Iterator<AggregateResult> Iterator(){
        return new SearchResultIterator(this.query);
    }
}

//インタフェースIterator
public class SearchResultIterator Implements Iterator<AggregateResult>{
    public AggregateResult [] results {get;set;}
    public Integer index {get;set;}

    public SearchResultIterator(String query){
        this.index = 0;
        results = Database.query(query);
    }

    public boolean hasNext(){
        return results !=null && !results.isEmpty() && index < results.size();
    }

    public AggregateResult next(){
        return results[index++];
    }
}

// Run batch apex
SampleAggregateBatch batch = new SampleAggregateBatch();
Database.executebatch(batch, 200);

// Debug log output
>>>> COUNT : 1
>>>> COUNT : 3
>>>> COUNT : 2