Skip to main content
Premawati . (Deloitte USI) 님이 #Collaboration에 질문했습니다

trigger AccountAddressTrigger on Account (before insert, before update) {

List<Account> acc=new List<Account>();

Set<Id> accid=new Set<Id>();

List<Account> accAdd=new List<Account>();

for(Account acc1:Trigger.new)

{

accid.add(acc1.id);

}

acc=[select Name,Match_Billing_Address__c,Id,ShippingPostalCode,BillingPostalCode from Account where Id IN:accid];

System.debug('Check the Value in acc='+acc);

for(Account acc2:acc)

{

System.debug('checkbox value='+acc2.Match_Billing_Address__c);

if(acc2.Match_Billing_Address__c==True)

{

acc2.ShippingPostalCode=acc2.BillingPostalCode;

System.debug('Shipping ZIp COde='+acc2.ShippingPostalCode);

}

}

//update accAdd;

}

 

 
답변 1개
  1. 2018년 7월 7일 오후 4:57
    Hi,

     

    Your trigger should look like this:

     

     

    trigger AccountAddressTrigger on Account (before insert, before update) {

    for(Account acc1:Trigger.new)

    {

    if(acc1.Match_Billing_Address__c==True)

    acc1.ShippingPostalCode=acc1.BillingPostalCode;

    }

    }