function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
veeru417veeru417 

need help:implementing functionality like Copy Billing Address to Shipping Address in accounts

Is it possible to implement  a functionality like Copy Billing Address to Shipping Address link (which is avilable in account object Address Information pageblock )  in my custom object

Best Answer chosen by Admin (Salesforce Developers) 
AmitSahuAmitSahu

Yes possible.. 

 

1. Use Apex class to write a controller to get the address wherever you want.

2. Write a VF Page using the controller to call the function in the class

3. Create a button to call this VF page 

All Answers

AmitSahuAmitSahu

Yes possible.. 

 

1. Use Apex class to write a controller to get the address wherever you want.

2. Write a VF Page using the controller to call the function in the class

3. Create a button to call this VF page 

This was selected as the best answer
SamuelDeRyckeSamuelDeRycke

I would use a trigger, like such:

 

trigger AccountTrigger on Account (before insert, before update) {
	
	List<Account> lst_in = trigger.new;
	for(Account acc:lst_in){
		
		if(acc.BillingCity != null && acc.ShippingCity == null){
			acc.ShippingCity = acc.BillingCity;
		}
		//repeat for other fields
	}
}

 

veeru417veeru417

hi,

I am new to this technology,i am learning on my own.can you suggest any doc or site to learn  apex class in better way.

veeru417veeru417

i want  to implement  functionality like whenever i  click the link then only it will copy  the field value into specified field.Is it possible?Help me in developing that.

Thanks,

veerendranath 

 

SamuelDeRyckeSamuelDeRycke

Not sure what you mean by "whenever i click the link"

 

If you're new, there is a lot of documentation on developer.force.com, in example: http://wiki.developerforce.com/page/Forcedotcomworkbook

 

Have a look at the forc.com, apex, visual force and database workbooks, they helped me out a lot.

SFDCTech1SFDCTech1

Can anyone give in detail with code so that whenever i click on button shipping address to copy into billing address

SFDCTech1SFDCTech1

i have wriiten trigger like this . Can you check and give me some output . i want two issues to solve in this code 

 

1. Can we reduce the code in a smarter way as iam new i written like this.

1. it is only working when we save record for first time. i mean if we edit that and again save it is not reflecting.

 

Can you please solve as it is very urgent for me.

 

trigger AccountTrigger on Account (before insert, before update) {
    
    List<Account> lst_in = trigger.new;
    for(Account acc:lst_in){
        
        if(acc.ShippingCity != null && acc.BillingCity == null ){
            acc.BillingCity = acc.ShippingCity;
              }
    if(acc.ShippingStreet != null && acc.BillingStreet == null){
           acc.BillingStreet = acc.ShippingStreet;
            
           }
    if(acc.ShippingState != null && acc.BillingState == null){
            acc.BillingState = acc.ShippingState;
            
            }
   if(acc.ShippingPostalcode != null && acc.BillingPostalcode == null){
            acc.BillingPostalcode = acc.ShippingPostalcode;
            
           }
   if(acc.ShippingCountry != null && acc.BillingCountry == null){
            acc.BillingCountry = acc.ShippingCountry;
            
           }        
}
}