• Ashish Singh SFDC
  • NEWBIE
  • 220 Points
  • Member since 2018
  • Salesforce Developer and Administrator
  • RightKliq


  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 33
    Replies
 Below code was intended to do dynamic search on Case object and display results in pageblocktable. Now, I have added inlineEditSupport and save function to it. As I want to save values in inputField "Case Review Notes" field (Case_Comments_On_VFReport__c). When I click on Save button, it does save value, but only on UI. When I refresh page, value is gone. Also when I tried to query Case_Comments_On_VFReport__c in devconsole I don't see any update on this field.
I am just trying to get hands on Visualforce page and Apex. Can you guys please help me here with code?

Visualforce Page:
<apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock>

            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
            </apex:pageblockSection>
            
            <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
            </apex:pageBlock>
 
        <apex:pageBlock title="Case Details" id="details" rendered="{! IF( caseList != null && caseList.size >0, true, false)}" mode="edit">
            <apex:pageBlockTable value="{!caseList}" var="c">  
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
                <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/> 
                <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Severity__c}" headerValue="Priority"/>
                <apex:column headerValue="Case Review Notes">
                    <apex:inputField value="{!c.Case_Comments_On_VFReport__c}" />
                </apex:column>
            </apex:pageBlockTable>
           <apex:inlineEditSupport />
            
                    <!---Save Button -->
                    <apex:pageBlockButtons html-align="left" location="top">
                          <apex:commandButton value="Save" action="{!save}" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VF_CaseSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCase**s** ();
      conditions.clear();
  }
  
  
  public Void searchCase**s**(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, CreatedDate, Status, Severity__c, Case_Comments_On_VFReport__c, FROM Case';
    
      if(cas.SAC__c !=null && cas.SAC__c !=''){
          conditions.add('SAC__c Like\'%' +cas.SAC__c +'%\' ');
      }
           
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);
  }
    
     // Save button
     public PageReference save(){
        try{
            Database.update(caseList);
            system.debug('caseList'+ caseList);
            return ApexPages.CurrentPage();
        }
        catch(DMLException e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getMessage()));
        }
        return null;
    }
}


 
Hello All,
Having an issue passing a list to another method within a class.

So I have this code:
public list<Cand__c> tc1;

 Cand__c tc1 = [my query]
How fo I pass the results of tc1 to another method in the class?
This code below is not working.  The list is null
public void summary ( list<Cand__c> new cand)

Any suggestions would be greatly appreciated.

Cheers,
P


 
So basically i have a page that is going through case creation, if the contact doesn't exist it, there is a button that shows the user a contact creation section.
When I press save I get errors that make no sense.

Visualforce
<apex:page Controller="CaseProcess" lightningStylesheets="true" >
    <apex:form >
        <apex:pageBlock Title ="Case Creation">
            <apex:pageMessages></apex:pageMessages>
            <apex:pageBlockSection title="Case Setup" id="caseSetup">
                <apex:inputField value="{!newCase.Subject}" required="true"/>
                <apex:inputField value="{!newCase.Origin}" required="true"/>
                <apex:inputField value="{!newCase.AccountId}" required="true"/>
                <apex:inputField value="{!newCase.RecordTypeId}" required="true"/>
                <apex:inputField value="{!newCase.ContactId}" required="true"/>
                <apex:inputField value="{!newCase.EntitlementId}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection>
                <apex:commandButton value ="New Contact" action = "{!showCreateContact}" rendered = "{!notWizardContactSection}" immediate="true" html-formnovalidate="formnovalidate" style="align-content: center">
                	<apex:actionSupport reRender="contactCreation" />
            	</apex:commandButton>
            </apex:pageBlockSection> 
            <apex:commandbutton value="Save Case" action="{!saveCase}"/> 
    		<apex:commandbutton value="Cancel" action="{!cancelCase}" immediate="true" html-formnovalidate="formnovalidate"/>
        </apex:pageBlock> 
        <apex:pageBlock id="contactCreation" rendered="{!wizardContactSection}" title="Contact Creation">
            <!-- create contact section -->   
            <apex:pageBlockSection >
                <apex:inputField value="{!newContact.Name}"/>
            	<apex:inputField value="{!newContact.FirstName}" />
                <apex:inputField value="{!newContact.LastName}" id="lastName" />
                <apex:inputField value="{!newContact.AccountId}" id="accountId"/>
                <apex:inputField value="{!newContact.Email}" />
                <apex:inputField value="{!newContact.MobilePhone}" />
            </apex:pageBlockSection>  
            <apex:pageBlockSection>
                <apex:commandButton value ="Save Contact" action = "{!saveContact}" immediate="true" html-formnovalidate="formnovalidate">
                    <apex:actionSupport reRender="contactCreation" />
                </apex:commandButton>
            </apex:pageBlockSection>
            <!-- buttons section -->
        </apex:pageBlock>
    </apex:form>
</apex:page>
Controller
 
public class CaseProcess {

    public Contact newContact{get; set;}
    public Case newCase{get; set;}

    
    // assign variables for the different sections of the form
    public boolean wizardContactSection{get; set;}
    public boolean notWizardContactSection{get; set;}
    
    public CaseProcess(){
        // assign variables for hidding and showing sections of the form
        newCase = new Case();
        newContact = new Contact();
        wizardContactSection = false;
        notWizardContactSection = true;
    }
    public pagereference cancelCase(){
        return new pagereference('/lightning/o/Case/list');
    }
    public pagereference saveCase(){
        newCase.Status = 'New';
        insert newCase;
        return new pagereference('/lightning/o/Case/list');
    }
    
    public void showCreateContact(){
        wizardContactSection = true;
        notWizardContactSection = false;
        newContact.AccountId = newCase.AccountId;
    }
    public void saveContact(){
        /*
        if (newContact.AccountId == null){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please add an account to the contact.'));
            return;
        }*/
        try{
            insert newContact;    
        	newCase.ContactId = newContact.Id;
        	wizardContactSection = false;
        }
        catch(DmlException ex){
        	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getDmlMessage(0)));   
        }
    }

}

And error message
User-added image
I can't work out why, I have tried moving all the contact related stuff into an extention but that doesn't work either 

 
Hello, our Contact object has a lookup to our Lead object. When a Lead is inserted or updated, and certain custom fields are not null, a trigger automatically creates a Contact record. One of those custom Lead fields is a rich text area, because after the Contact is inserted, we want to turn that into a hyperlink which can be clicked on to go straight to the Contact record. What would you advise as the best way to do this? Any help in building the trigger would be greatly appreciated. 
I have created a VF page using a custom controller and I wanted to change background colour of the pageblocksection as it defaults to blue. The issue is it changes in the preview but when I add it to sites it defaults to blue.

Preview:
User-added image
Using Sites:

User-added image
<apex:page controller="i2" >
    <style>
.bPageBlock {
border-top: 0px;
}
</style>
    <apex:form>
        <apex:pageBlock title="Invoice" mode="maindetail">
            
            
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            <apex:pageblockButtons location="Bottom" >
                <apex:commandButton action="{!save}" value="save" >
                </apex:commandButton>
            </apex:pageblockButtons>
            
            
            <apex:pageBlockSection columns="1" title="Invoice Details">
                <apex:inputField value="{!acc.Name}"/>
                <apex:inputField value="{!acc.Total_Amount__c}"/>
                <apex:inputField value="{!acc.Password__c}"/>
             	
   
            	</apex:pageBlockSection> 
            
            
            <apex:pageBlockSection columns="1" title="Invoice Line Items Details">
                <apex:inputField value="{!abb.Name}"/>
                <apex:inputField value="{!abb.Price__c}"/>
                <apex:inputField value="{!abb.Invoice__c}"/>
            </apex:pageBlockSection> 
            
        </apex:pageBlock>
    </apex:form>
    
    
    
</apex:page>

 
Hi Friends,

I have a requirement, where I need to insert child records based on date difference.

Below details:
After insert trigger on Order to insert a child custom object based on start date and end date difference.
For Eg: Start Date = 28/02/2020 and End Date = 28/03/2020.
Difference is 29 days and I want to create 29 child records.

How can I start writing the trigger. Kindly give your suggestions.

Thanks in Advance.
I have a visualforce page and a custom controller
vf page have a form and required fields and i'm validating it throught <apex:inputtext value="{!data}" required="true">

my question is do I need to validate it in my controller also?
like if
if(data == Null || data == ''){
   pexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'my error message'));
}
i'm really confused about it.

please help.


 
trigger BaltimoreNo on Account (before insert) {
    for (Account acc : Trigger.new){
        if (acc.BillingCity='Baltimore'){
            alert ('Company XYZ will not do business in city of Baltimore');
     
        }
    }
}
Hi all,

I've requirement where we are want to move from Unlimited edition to enterprise edition. If someone has done it in past, could you please help us with consideration, challenges, checklist, etc.

I've already explored lot of conent on web but couldn't found much relevant information. 

Thanks,
Ashish Singh.
Hi Experts,

I have requirement to write a trigger on user object. Whenever a user is created or updated based on the profile, I need to assign the permission set. I have created 2 custom object for this: Profile__c (master) and Permission_Set__c(detail). In Profile I have Saved a record name__c: "Standard Employee" and Id__c="15 digit Id " of real profile & same way I have created 3 records in Permission Set with name__c with original name of Permission Set and Id__c for its child record.  I have to do this using custom object because we have around 124 permission Set which will continued to be added.

Trigger :
trigger permissionSetAssignment on User(after insert, after update){
    if(trigger.IsAfter && trigger.IsInsert){
        PermissionSetAssignment_Handler.afterInsert(Trigger.new);
    }
    if(trigger.IsAfter && trigger.IsUpdate){
        PermissionSetAssignment_Handler.afterUpdate(Trigger.oldMap,Trigger.new);
    }
}

Handler Class for Update:

public class PermissionSetAssignment_Handler {
    public static void afterInsert(List<User> users){
     /* Logic Yet to be written*/      
    }
    public static void afterUpdate(Map<Id,User> oldUsers, List<User> newUsers){
        Set<Id> userIds = new Set<Id>();
        Map<Id,User> userPerm = new Map<Id,User>();
        List<PermissionSetAssignment> insertList = new List<PermissionSetAssignment>();
        for(User u:newUsers){
            User checkUser = oldUsers.get(u.ID);
            if(u.ProfileId != checkUser.ProfileId){
                userIds.add(u.Id);
            }
        }
        List<PermissionSetAssignment> psa = [Select Id from PermissionSetAssignment where assigneeId in:userIds and permissionSetId in (Select Id from PermissionSet where IsOwnedByProfile=False)];
        delete psa;
        List<Profile__c> profiles = [SELECT Id,Id__c,name,(Select Id,Id__c,name from Permission_Sets__r) FROM Profile__c];
        List<Permission_Set__c> permissionSets = [Select Id,Id__c from Permission_Set__c];
        for(User u:newUsers){
            for(Profile__c pc:profiles){
 /* Here I am stucked I want to fetch only those permissionSets which are under under profile but with below code I'll end up adding all permission Sets */               
                if(u.ProfileId == pc.Id__c){                   
                    for(permission_Set__c ps:permissionSets){
                    PermissionSetAssignment sep = new PermissionSetAssignment();
                    sep.AssigneeId=u.id;
                    sep.PermissionSetId=ps.Id__c;
                    insertList.add(sep);
                    }
                }
            } 
    }
            insert  insertList;        
}
}
 Below code was intended to do dynamic search on Case object and display results in pageblocktable. Now, I have added inlineEditSupport and save function to it. As I want to save values in inputField "Case Review Notes" field (Case_Comments_On_VFReport__c). When I click on Save button, it does save value, but only on UI. When I refresh page, value is gone. Also when I tried to query Case_Comments_On_VFReport__c in devconsole I don't see any update on this field.
I am just trying to get hands on Visualforce page and Apex. Can you guys please help me here with code?

Visualforce Page:
<apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock>

            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
            </apex:pageblockSection>
            
            <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
            </apex:pageBlock>
 
        <apex:pageBlock title="Case Details" id="details" rendered="{! IF( caseList != null && caseList.size >0, true, false)}" mode="edit">
            <apex:pageBlockTable value="{!caseList}" var="c">  
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
                <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/> 
                <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Severity__c}" headerValue="Priority"/>
                <apex:column headerValue="Case Review Notes">
                    <apex:inputField value="{!c.Case_Comments_On_VFReport__c}" />
                </apex:column>
            </apex:pageBlockTable>
           <apex:inlineEditSupport />
            
                    <!---Save Button -->
                    <apex:pageBlockButtons html-align="left" location="top">
                          <apex:commandButton value="Save" action="{!save}" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VF_CaseSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCase**s** ();
      conditions.clear();
  }
  
  
  public Void searchCase**s**(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, CreatedDate, Status, Severity__c, Case_Comments_On_VFReport__c, FROM Case';
    
      if(cas.SAC__c !=null && cas.SAC__c !=''){
          conditions.add('SAC__c Like\'%' +cas.SAC__c +'%\' ');
      }
           
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);
  }
    
     // Save button
     public PageReference save(){
        try{
            Database.update(caseList);
            system.debug('caseList'+ caseList);
            return ApexPages.CurrentPage();
        }
        catch(DMLException e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getMessage()));
        }
        return null;
    }
}


 
Hi! I want to create a class that will fetch the ID of an Account dynamic when I create a new record. We have a custom object named Account Change request. This object can be found in the related lists from Account. When user press to create a new Account Change Request I want to override it with my visualforce page, thus I would need to display the informations on my VF page from that Account. I tried to create by myself but it's not working..
 
public class MasterDataChange{


 public Account parentAccount{get; set;}
 public Account_Change_Request__c accChangeRequest;


 public MasterDataChange(ApexPages.StandardController controller){
    
  String parentAccId = ApexPages.currentPage().getParameters().get('id');
     if(parentAccId != null){
            parentAccount= [SELECT Id, Name FROM Account WHERE Id = :parentAccId limit 1];
                accChangeRequest.Account__c = parentAccount.Id;
            }
         
        } 

  
 public PageReference save(){
   insert accountChangeRequest;
   
    PageReference pg = new PageReference('/'+parentAccount.Id);
          pg.setRedirect(true);
         return pg;
 }
}

Account__c is my master-detail with the Account object.. please help.
Hello All,
Having an issue passing a list to another method within a class.

So I have this code:
public list<Cand__c> tc1;

 Cand__c tc1 = [my query]
How fo I pass the results of tc1 to another method in the class?
This code below is not working.  The list is null
public void summary ( list<Cand__c> new cand)

Any suggestions would be greatly appreciated.

Cheers,
P


 
code is:
List<Id> rectypeId=new List<Id>();
            for(RecordType r:[Select Id,Name from RecordType where sObjectType ='Contact' AND DeveloperName IN('Contact')]){
              rectypeId.add(r.Id);
              }
Here how we can add constant variable for "DeveloperName IN('Contact')".

thanks,
Chandu
hi, I'm hoping someone can point me in the right direction.
I have a vf page to search child object related to Opportunity.
In input user have to insert two string Inputtext (owner and id opportunity).
In apex class there is a void method load data:
Apex class:
public class SearchWithWrapperSS {
    
    public  Date StartDate {get;set;}
    public  Date EndDate {get;set;}
    public String inputValue1 {get;set;}
    public String inputValue2 {get;set;} 
    public List<WrapperClass> listBD {get;set;}
    
    public List<Billing_Detail__c> blst=new List<Billing_Detail__c>();
    
    
    public void loadData() {
        if ((! String.isBlank(inputValue1))&&(String.isBlank(inputValue2))){
            String Owner;
            
            List <User> userList = [Select id, Name from User where Email =: inputValue1];
            if(! userList.isEmpty()){ 
             Owner = userList[0].id; 
            
            
            
            List <Billing_Detail__c> billingList = [Select Id,Account_Name__c,SF_Opportunity_Id__c, Name,Billing_Type__c, 
                                                    Billing_Period__c , Monthly_Forecast__c,Billing_Competence_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c 
                                                    from Billing_Detail__c 
                                                    Where Billing_Detail__c IN (select id from Opportunity where OwnerId=:Owner)and 
                                                    Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate and Billing_Status__c !='Billed' 
                                                    Order by Monthly_Forecast__c ];
            
            
            listBD = new List<WrapperClass>();
            for(Billing_Detail__c  cr : billingList ){
                listBD.add(new WrapperClass (cr, false));
            }
            
            }
            
        }
        
        else if ((! String.isBlank(inputValue1))&&(! String.isBlank(inputValue2))){
            String Owner;
            List <User> userList = [Select id, Name from User where Email =: inputValue1];
          if(! userList.isEmpty()){ 
             Owner = userList[0].id; 
            
            List <Billing_Detail__c> listBilling = [Select Id,Account_Name__c,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,Billing_Competence_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c 
                                                    from Billing_Detail__c Where Billing_Detail__c IN (select id from Opportunity where OwnerId=:Owner)
                                                    and Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate and SF_Opportunity_Id__c=:inputValue2 and Billing_Status__c !='Billed' Order by Monthly_Forecast__c ];
            
            listBD = new List<WrapperClass>();
            for(Billing_Detail__c  cr : listBilling){
                listBD.add(new WrapperClass (cr, false));
                
            }
        }
        }
        
        else if (! String.isBlank(inputValue2)){
            listBD = new List<WrapperClass>();

            for(Billing_Detail__c  cr : [Select Id,Account_Name__c,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,Billing_Competence_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c   from Billing_Detail__c Where Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate and SF_Opportunity_Id__c=:inputValue2 and Billing_Status__c !='Billed' Order by Monthly_Forecast__c ]){
                listBD.add(new WrapperClass (cr, false));
            }
        }
        else{
            listBD = new List<WrapperClass>();
            for(Billing_Detail__c  cr : [Select Id,Account_Name__c,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,Billing_Competence_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c   from Billing_Detail__c Where Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate and Billing_Status__c !='Billed'  Order by Monthly_Forecast__c ]){
                listBD.add(new WrapperClass (cr, false));
                
            }
        }
        
    }  
    public List<WrapperClass> getBilling() {
        if(listBD == null) {
            
            listBD = new List<WrapperClass>(); 
            for(Billing_Detail__c  cr : [Select Id,Account_Name__c,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,Billing_Competence_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c   from Billing_Detail__c Where Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate and Billing_Status__c !='Billed' Order by Monthly_Forecast__c ]){
                listBD.add(new WrapperClass (cr, false));
            }
        }   
        return listBD;
    }
    
    
    
    
    
    public PageReference changeStatus() {
        
        List<Billing_Detail__c> selectedBD = new List<Billing_Detail__c>();
        for(WrapperClass bd: getBilling()){
            
            Billing_Detail__c billlingDetail ;
            if(bd.check_box== true){
                
                billlingDetail = new Billing_Detail__c(Id=bd.cs.Id);
                billlingDetail.Billing_Status__c= 'Authorized for Billing';
                
                
                selectedBD.add(billlingDetail);
                
            } 
        }
        
        update selectedBD;
        loadData();
        
        
        
        return null;
    }   
    public PageReference processSelected() {
        
        List<Billing_Detail__c> selectedBD = new List<Billing_Detail__c>();
        for(WrapperClass bd: getBilling()){
            
            Billing_Detail__c billlingDetail ;
            if(bd.check_box== true){
                
                billlingDetail = new Billing_Detail__c(Id=bd.cs.Id);
                if (bd.cs.Monthly_Forecast__c.month()==12)
                {
                    billlingDetail.Monthly_Forecast__c = Date.newinstance(  bd.cs.Monthly_Forecast__c.year()+1 , 01 ,  bd.cs.Monthly_Forecast__c.day() );
                    
                    billlingDetail.Billing_Competence_Forecast__c  = billlingDetail.Monthly_Forecast__c;
                    selectedBD.add(billlingDetail);
                }
                
                
                else{
                    
                    billlingDetail.Monthly_Forecast__c = Date.newinstance(  bd.cs.Monthly_Forecast__c.year() , bd.cs.Monthly_Forecast__c.month()+1,  bd.cs.Monthly_Forecast__c.day() );
                    
                    
                    billlingDetail.Billing_Competence_Forecast__c  = billlingDetail.Monthly_Forecast__c;
                    selectedBD.add(billlingDetail);
                }   
                
            } 
        }
        
        
        update selectedBD;
        loadData();
        
        return null;       
    }
    
    
    
    //save
    public PageReference toSave() {
        List<Billing_Detail__c> selectedBD = new List<Billing_Detail__c>();
        for(WrapperClass bd: getBilling()){
            
            Billing_Detail__c billlingDetail ;
            
            
            billlingDetail = new Billing_Detail__c(Id=bd.cs.Id,Amount__c=bd.cs.Amount__c, Billing_Type__c=bd.cs.Billing_Type__c,Billing_Competence_Forecast__c=bd.cs.Billing_Competence_Forecast__c, Billing_Period__c=bd.cs.Billing_Period__c, Billing_Status__c=bd.cs.Billing_Status__c, Monthly_Forecast__c=bd.cs.Monthly_Forecast__c,End_of_Billing__c=bd.cs.End_of_Billing__c );               
            
            selectedBD.add(billlingDetail);      
        }
        
        update selectedBD;
        loadData();
        
        return null;
    }
    

    public PageReference toDelete() {
        List<Billing_Detail__c> selectedBD = new List<Billing_Detail__c>();
        for(WrapperClass bd: getBilling()){
            
            Billing_Detail__c billlingDetail ;
            if(bd.check_box== true){
                
                billlingDetail = new Billing_Detail__c(Id=bd.cs.Id);               
                
                selectedBD.add(billlingDetail);
                
            } 
        }
        
        delete selectedBD;
        loadData();
        
        return null;
    }
    

    
    public class WrapperClass {
        public Billing_Detail__c  cs {get; set;}
        public Boolean check_box {get; set;}
        
        public WrapperClass(Billing_Detail__c  c, Boolean check_box){
            this.cs = c;
            this.check_box = false;
        }
    }
}

the test class:
@isTest private class SearchWithWrapperSSTest {
@isTest static void testController() {
    Test.startTest();
    Id RecordTypeIdAccount = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Customer_user').getRecordTypeId();//get only macrostructure RT		
    // create the object in input of the class 
        Account a= new Account();
        a.name='Account test t';
        //a.RecordTypeId='012w0000000iROM';
        a.Branch__c='Italy';
        a.Status__c='Customer';
        a.BillingCountry='Italy';
        a.Public_Administration_Account__c='No';
        insert a;

		Opportunity testOpportunity = new Opportunity(
		AccountID = a.Id,
		Name = 'Test Opportunity',
		StageName = 'Needs Analysis',
		CloseDate = date.today().addDays(15)       		
		);
		insert testOpportunity;
    
    
    
    Billing_Detail__c c= new Billing_Detail__c(); 
		c.Amount__c= 100;
		c.Billing_Type__c='FEE';
		c.Billing_Period__c='monthly';
		c.Billing_Status__c='Authorized for Billing'; 
		c.Product_Line__c='Interactive Experience (iX)'; 
		c.Product__c='Chat Delivery'; 
		c.Monthly_Forecast__c=Date.newInstance(2018, 7, 9); 
		c.End_of_Billing__c=Date.newInstance(2019, 7, 9); 
		c.Billing_Detail__c=testOpportunity.Id;

		insert c;
         
        User u = new user();
        u.LastName = 'Admin';
        u.Email = 'test1@test.com';
        u.Alias = 'Tcode';
        u.Username = 'test123@test.com.testClass';
        u.CommunityNickname = 'test121';
        u.LocaleSidKey = 'en_US';
        u.TimeZoneSidKey = 'GMT';
        u.ProfileId = [Select id, name from Profile where name = 'System Administrator' OR name = 'Amministratore del sistema'].id;
        u.LanguageLocaleKey = 'en_US';
        u.EmailEncodingKey = 'UTF-8';
        u.IsActive = true;
      
        insert u;
           
    	Date StartDate= Date.newInstance( 2018, 07,1);
    	Date EndDate= Date.newInstance(  2019,10,18 );
    	String inputValue1= 'test1@test.com';
    	String inputValue2= testOpportunity.SFDC_Opportunity_Id__c;

    
    list<WrapperClassTest> wrp= new  list<WrapperClassTest>();
   
    	ApexPages.StandardController sc = new ApexPages.StandardController(c);
SearchWithWrapperSS x =new  SearchWithWrapperSS();		
    	x.loadData();

    	x.listBD[0].check_box=true;
    for(WrapperClassTest wTest :wrp)
       
  {
   wTest.check_box=true;    
  }
    	
    	x.changeStatus();
    	x.processSelected(); 
    	x.toSave();
    	x.toDelete();
    
	
	
     Test.stopTest();
}
    Public class WrapperClassTest{
        public Billing_Detail__c  cs {get;set;}
        public Boolean check_box {get;set;}
        public WrapperClassTest(Billing_Detail__c  c, Boolean check_box)
        {
            this.cs = c;
            this.check_box = false;
        }
       public WrapperClassTest(Billing_Detail__c c) {
            this.cs = c;
            this.check_box = false;
        }
    }

}


The code coverage is 61% but i don't understand why it's like it doesn't see the content of the inputValue1 and inputValue2.
I'm hoping someone could have a look at my test class and let me know how I should go about passing these parameters.
any help would be appreciated 
Thanks
 
So basically i have a page that is going through case creation, if the contact doesn't exist it, there is a button that shows the user a contact creation section.
When I press save I get errors that make no sense.

Visualforce
<apex:page Controller="CaseProcess" lightningStylesheets="true" >
    <apex:form >
        <apex:pageBlock Title ="Case Creation">
            <apex:pageMessages></apex:pageMessages>
            <apex:pageBlockSection title="Case Setup" id="caseSetup">
                <apex:inputField value="{!newCase.Subject}" required="true"/>
                <apex:inputField value="{!newCase.Origin}" required="true"/>
                <apex:inputField value="{!newCase.AccountId}" required="true"/>
                <apex:inputField value="{!newCase.RecordTypeId}" required="true"/>
                <apex:inputField value="{!newCase.ContactId}" required="true"/>
                <apex:inputField value="{!newCase.EntitlementId}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection>
                <apex:commandButton value ="New Contact" action = "{!showCreateContact}" rendered = "{!notWizardContactSection}" immediate="true" html-formnovalidate="formnovalidate" style="align-content: center">
                	<apex:actionSupport reRender="contactCreation" />
            	</apex:commandButton>
            </apex:pageBlockSection> 
            <apex:commandbutton value="Save Case" action="{!saveCase}"/> 
    		<apex:commandbutton value="Cancel" action="{!cancelCase}" immediate="true" html-formnovalidate="formnovalidate"/>
        </apex:pageBlock> 
        <apex:pageBlock id="contactCreation" rendered="{!wizardContactSection}" title="Contact Creation">
            <!-- create contact section -->   
            <apex:pageBlockSection >
                <apex:inputField value="{!newContact.Name}"/>
            	<apex:inputField value="{!newContact.FirstName}" />
                <apex:inputField value="{!newContact.LastName}" id="lastName" />
                <apex:inputField value="{!newContact.AccountId}" id="accountId"/>
                <apex:inputField value="{!newContact.Email}" />
                <apex:inputField value="{!newContact.MobilePhone}" />
            </apex:pageBlockSection>  
            <apex:pageBlockSection>
                <apex:commandButton value ="Save Contact" action = "{!saveContact}" immediate="true" html-formnovalidate="formnovalidate">
                    <apex:actionSupport reRender="contactCreation" />
                </apex:commandButton>
            </apex:pageBlockSection>
            <!-- buttons section -->
        </apex:pageBlock>
    </apex:form>
</apex:page>
Controller
 
public class CaseProcess {

    public Contact newContact{get; set;}
    public Case newCase{get; set;}

    
    // assign variables for the different sections of the form
    public boolean wizardContactSection{get; set;}
    public boolean notWizardContactSection{get; set;}
    
    public CaseProcess(){
        // assign variables for hidding and showing sections of the form
        newCase = new Case();
        newContact = new Contact();
        wizardContactSection = false;
        notWizardContactSection = true;
    }
    public pagereference cancelCase(){
        return new pagereference('/lightning/o/Case/list');
    }
    public pagereference saveCase(){
        newCase.Status = 'New';
        insert newCase;
        return new pagereference('/lightning/o/Case/list');
    }
    
    public void showCreateContact(){
        wizardContactSection = true;
        notWizardContactSection = false;
        newContact.AccountId = newCase.AccountId;
    }
    public void saveContact(){
        /*
        if (newContact.AccountId == null){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please add an account to the contact.'));
            return;
        }*/
        try{
            insert newContact;    
        	newCase.ContactId = newContact.Id;
        	wizardContactSection = false;
        }
        catch(DmlException ex){
        	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getDmlMessage(0)));   
        }
    }

}

And error message
User-added image
I can't work out why, I have tried moving all the contact related stuff into an extention but that doesn't work either 

 
Hello, our Contact object has a lookup to our Lead object. When a Lead is inserted or updated, and certain custom fields are not null, a trigger automatically creates a Contact record. One of those custom Lead fields is a rich text area, because after the Contact is inserted, we want to turn that into a hyperlink which can be clicked on to go straight to the Contact record. What would you advise as the best way to do this? Any help in building the trigger would be greatly appreciated. 
Here are the steps I followed using a trigger but its not happening. Please help. Maybe I am missing something

1. I created a new field of Checkbox type on Contact Object to Flag contact as Key Contact
Field Name : Key_Contact__c
type : Checkbox
Object : Contact


2. The Trigger Class to Link Contacts That Flagged as key Contact when creating an Opportunity.


------------------------------------START------------------------------------------------
trigger LinkContacts on Opportunity (before insert, before update) {
   
set<Id> AccountIds = new set<Id>();
for (Opportunity  o: trigger.new) {
 AccountIds.add(o.AccountId);
}
map<Id, Account> AccountContactMap = new map<Id, Account>();
map<Id, Contact> ContactMap = new map<Id, Contact>();
list<Account> AccConts = new list<Account>();
AccConts = [Select Id, Name, (Select Id, Name, Key_Contact__c from Contacts Where Key_Contact__c = true) from Account where Id IN : AccountIds];
for(Account acc : AccConts){
    AccountContactMap.put(acc.Id, acc);
}

for (Opportunity  o: trigger.new) {
Account Acc = AccountContactMap.get(o.AccountId);
if(Acc != null){
List<Contact> conts = new list<Contact>(Acc.Contacts);
                 map<Id, Contact> ContactMap = new map<Id, Contact>();
                  Contact Con = ContactMap.get(o.ContactId);
if(conts.size() > 0 ){
                   
                    if(Con.Key_Contact__c = true){
                       
                        for(Contact contactFlag : conts){
    ContactMap.put(contactFlag.Id,con );
}
                    }

}
}


}
}

--------------------------------------END-------------------------------------------------

 
File is getting dowload..!
1)Need to print the records in the Row by Row..as ALL RECOREDS  is printing in a single row..
 
public class TesttabEliminated{

public list<account> lstaccount{get;set;}
public TesttabEliminated(){

 lstaccount = new list<account>();
 lstaccount =[select id, name from account limit 5];
 
} 
 
}
V.F:
<apex:page controller="TesttabEliminated"   contentType="text/plain/#test.txt">
   <apex:repeat value="{!lstaccount}"  var="a">
 {!a.id}    {!a.name}
 </apex:repeat>
  
</apex:page>

ANY SUGGESTIONS TO PRINT IN THE NEXT ROW WITH THE TABELIMINATED FORMAT.. 

THANKS,
dEEPIKA

 
I have created a VF page using a custom controller and I wanted to change background colour of the pageblocksection as it defaults to blue. The issue is it changes in the preview but when I add it to sites it defaults to blue.

Preview:
User-added image
Using Sites:

User-added image
<apex:page controller="i2" >
    <style>
.bPageBlock {
border-top: 0px;
}
</style>
    <apex:form>
        <apex:pageBlock title="Invoice" mode="maindetail">
            
            
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            <apex:pageblockButtons location="Bottom" >
                <apex:commandButton action="{!save}" value="save" >
                </apex:commandButton>
            </apex:pageblockButtons>
            
            
            <apex:pageBlockSection columns="1" title="Invoice Details">
                <apex:inputField value="{!acc.Name}"/>
                <apex:inputField value="{!acc.Total_Amount__c}"/>
                <apex:inputField value="{!acc.Password__c}"/>
             	
   
            	</apex:pageBlockSection> 
            
            
            <apex:pageBlockSection columns="1" title="Invoice Line Items Details">
                <apex:inputField value="{!abb.Name}"/>
                <apex:inputField value="{!abb.Price__c}"/>
                <apex:inputField value="{!abb.Invoice__c}"/>
            </apex:pageBlockSection> 
            
        </apex:pageBlock>
    </apex:form>
    
    
    
</apex:page>