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
S N 27S N 27 

Copy field values to another in apex

Hi All, 
I have a requirement wherein a table has to be designed(attached wireframe). The top 4 rows has to be static with the various roles pre-populated. 
Wireframe for Roles
The table is kind of static with individual div's. The problem is I have a copy button on the left that when clicked will show a popup and allow the user to copy the field values. Eg: I click on copy besides billing customer , I have an option to copy from the above 2 rows. Currently I have made use of action support and written an apex method which does the copy. But this is eats up lots of lines of code. I want to simplify the copy process. Any help will be highly appreciated.
Sample copy method is:
public String copyRoleData(){
        system.debug('copyRoleData>>>>>called>>>>>>>');
        for(CopyApplicationRoleWrapper wrapp : copywrappers){
            system.debug('wrapp.copyselectedValue>>>>>>>>>>>'+wrapp.copyselectedValue);
            if(System.label.APPLICATIONROLE_Developer.equals(wrapp.copyselectedValue)){
              system.debug('I am the developer>>>>>>>>>>');
              system.debug('approleDevRec.First_Name__c>>>>>>>>>>>'+approleDevRec.First_Name__c);
              approleBillRec.First_Name__c = approleDevRec.First_Name__c;
              approleBillRec.Last_Name__c = approleDevRec.Last_Name__c;
              approleBillRec.Company_Name__c = approleDevRec.Company_Name__c;
              approleBillRec.Email__c = approleDevRec.Email__c;
              approleBillRec.Access_Type__c = approleDevRec.Access_Type__c;
              approleBillRec.Phone_Number__c = approleDevRec.Phone_Number__c;
              approleBillRec.Active__c = approleDevRec.Active__c;
              approleBillRec.Billing_City__c = approleDevRec.Billing_City__c;
              approleBillRec.Billing_Street__c = approleDevRec.Billing_Street__c;
              approleBillRec.Billing_State__c = approleDevRec.Billing_State__c;
              approleBillRec.Billing_Zip_Postal_Code__c = approleDevRec.Billing_Zip_Postal_Code__c;
              approleBillRec.Mailing_City__c = approleDevRec.Mailing_City__c;
              approleBillRec.Mailing_Street__c = approleDevRec.Mailing_Street__c;
              approleBillRec.Mailing_State__c = approleDevRec.Mailing_State__c;
              approleBillRec.Mailing_Zip_Postal_Code__c = approleDevRec.Mailing_Zip_Postal_Code__c;

            }
            if(System.label.APPLICATIONROLE_Application_Owner.equals(wrapp.copyselectedValue)){
              system.debug('I am the Application Owner>>>>>>>>>>');
              system.debug('approleDevRec.First_Name__c>>>>>>>>>>>'+approleAppOwnerRec.First_Name__c);
              approleBillRec.First_Name__c = approleAppOwnerRec.First_Name__c;
              approleBillRec.Last_Name__c = approleAppOwnerRec.Last_Name__c;
              approleBillRec.Company_Name__c = approleAppOwnerRec.Company_Name__c;
              approleBillRec.Email__c = approleAppOwnerRec.Email__c;
              approleBillRec.Access_Type__c = approleAppOwnerRec.Access_Type__c;
              approleBillRec.Phone_Number__c = approleAppOwnerRec.Phone_Number__c;
              approleBillRec.Active__c = approleAppOwnerRec.Active__c;
              approleBillRec.Billing_City__c = approleAppOwnerRec.Billing_City__c;
              approleBillRec.Billing_Street__c = approleAppOwnerRec.Billing_Street__c;
              approleBillRec.Billing_State__c = approleAppOwnerRec.Billing_State__c;
              approleBillRec.Billing_Zip_Postal_Code__c = approleAppOwnerRec.Billing_Zip_Postal_Code__c;
              approleBillRec.Mailing_City__c = approleAppOwnerRec.Mailing_City__c;
              approleBillRec.Mailing_Street__c = approleAppOwnerRec.Mailing_Street__c;
              approleBillRec.Mailing_State__c = approleAppOwnerRec.Mailing_State__c;
              approleBillRec.Mailing_Zip_Postal_Code__c = approleAppOwnerRec.Mailing_Zip_Postal_Code__c;
              
            }
        }
        return null;
    }
 
Jake William 4Jake William 4
My name is Jake and I offer Online Essay Help (http://www.EssayGlobe.co.uk/) I need more description could you please?
S N 27S N 27
@Jake William 4: The idea here is to have a table with 4 static rows (please find attached wireframe). These are basically 4 different roles. So when the user clicks on Copy button besides the 3rd row i.e. Billing customer, the user is presented with a popup having option to select the above two roles. Suppose the user selects Developer, then the data from the Developer row (First Name, Last Name, Company Name) etc. should get copied on to the Billing Customer. I haven't used the page Block Table since some of the fields in the first 2 rows have to be pre-filled. So the id's are generated dynamically when using Pageblock Table so will get difficult in pre-filling.