DocSF

DocSF

Did You Know?

Advanced visual search system powered by Ajax

Using Future Methods Trailhead Help

Classe

global class AccountProcessor {
	@future
    public static void countContacts(Set<id> setId){
        List<Account> lstAccount = [SELECT Id, Number_of_Contacts__c, (SELECT Id FROM Contacts) FROM Account where id in : setid];
        for(Account acc: lstAccount){
            List<Contact> lstCont=acc.contacts;
            	acc.Number_of_Contacts__c = lstCont.size();
        }
        update lstAccount;
    }
}

Test

@isTest private class AccountProcessorTest {
    @isTest static void countContacts() {
        Test.setMock(AccountProcessorTest.class, new Account());
        Test.startTest();
        	AccountProcessor.countContacts();			
        Test.stopTest();
        
    } 	
}

Related Post

Domande e risposte su Salesforce

Question 1) What is Salesforce?? Answer: Salesforce ...

Come eseguire comandi SOQL con Visual Studio

In questa guida si trovano informazioni su come usare V...

Webservices in Commerce Cloud

La guida ai webservice in commerce cloud è disponibile...

Leave a Comment