+ Start a Discussion
john2john2 

Add custom link to VF Page

Hi everyone,

can anyone helpme how to add custom link to vf page.

 

here is the scenario,

i am ovveriding the "NEW" Button in Acocunts. when we click the new button, vf page has to popup and we enter the fields and we will save that record. when we enter the billing address in the native page in the address information we have a link there saying that "Copy BillingAddress to Shipping Address".

 

i want to add that link to my vf page and and when i click that link shipping address will automatically update with the billing address.

 

can anyone helpme out how to write code for that in VF Page and Controller.

 

thanks in advance, 

bob_buzzardbob_buzzard

You could do this via the controller using a command link.  Assuming the input fields are contained in an outputpanel (or similar) with the id "detail":

 

Page:

 

 

<apex:commandLink value="Copy billing address to shipping address" action="{!copyAddress}" rerender="detail/>

 

 

Controller (assumes the account being created is stored in the variable "account"):

 

 

public void copyAddress()
{
   account.ShippingCity=account.BillingCity;

   // repeat as above for all address fields
}

 

 

 

 

 

 

 

tganikumartganikumar

Can you give me the total code? means how to write the code for custom copy billing address to shipping address link.

bob_buzzardbob_buzzard

Sorry, I don't have time to write code to give away to others to charge for

tganikumartganikumar

hi bob, its ok. And also i got the code, i only tried and i got it. Just it is given one error like

"new_account Compile Error: Incompatible types since an instance of SObject is never an instance of account", because of this, i ask the code. 

thanks bob

tganikumartganikumar

Bob, i have one question. I am getting error like below when i click on compile all classes link at top of apex classes section. and also it is showing the code coverage is 81% and once i vl click on Run all tests button it is giving 91 test error and test coverage is 0. Can you give me any idea about this?

 

 

line 14, column 9: Illegal assignment from LIST<Account> to account
line -1, column -1: Previous load of class failed: BillNew: line 14, column 9: Illegal assignment from LIST<Account> to account
line -1, column -1: Previous load of class failed: BillNew: line 14, column 9: Illegal assignment from LIST<Account> to account
line -1, column -1: Previous load of class failed: BillNew: line 14, column 9: Illegal assignment from LIST<Account> to account
line -1, column -1: Previous load of class failed: BillNew: line 14, column 9: Illegal assignment from LIST<Account> to account
line -1, column -1: Previous load of class failed: BillNew: line 14, column 9: Illegal assignment from LIST<Account> to account

 

thanks

ganesh