Skip to main content
RAHUL KUMAR SINGH (NA) が「#Apex」で質問
trigger Industryisbanking on Account (before insert) {

    for(account a : trigger.new )

    {

        if(a.industry == 'Banking')

        {

            a.ownership = 'Public';

        }

    }

}
6 件の回答
  1. 2017年12月8日 15:34
    Hi Rahul,

    After inserting, we need to query the same record then check values.

     

    @istest

    public class Industryisbankingtest

    {

    static testmethod void test5(){

    account ac = new account(name='Robin Ltd',Industry='Banking',Ownership='Private');

    test.startTest();

    insert ac ;

    test.stoptest();

    account act = [select id,name,Ownership from account where id =: ac.id];

    system.debug('==act=='+act);

    system.debug('==ac.ownershp=='+act.Ownership);

    system.assertEquals('Public' , act.ownership);

    }

    }

    Thanks

    Varaprasad

     
0/9000