• Gopal Agrawal
  • NEWBIE
  • 40 Points
  • Member since 2014
  • Salesforce Certified Developer
  • Twopir Consulting

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 29
    Replies
Hi,

I am running into some issues when running a test class in which I do a system.assert for a trigger on accounts I have written.
The trigger is relatively simple, it checks two fields on the account record and if changed or if a new account is created, it populates two other fields with corresponding values that I retrieve from a custom setting.

The trigger works fine when I test it in the UI, here is the code:
 
trigger BU_Update on Account (before insert, before update) {
    
    
    Map<String, String> DD1Values = new Map<String, String>(); //map to hold values from DD1 Custom Setting
    For(DD1_Definition__c dd1 : [SELECT DD1_Code__c, DD1_Business_Unit__c FROM DD1_Definition__c]){
        DD1Values.put(dd1.DD1_Code__c, dd1.DD1_Business_Unit__c);
    }
    Map<String, String> DD2Values = new Map<String, String>(); // map to hold values from DD2 Custom Setting
    For(DD2_Definition__c dd2 : [SELECT DD2_Code__c, DD2_Business_Unit__c FROM DD2_Definition__c]){
        DD2Values.put(dd2.DD2_Code__c, dd2.DD2_Business_Unit__c);
    }
    
    //Compare old and new values for DD1 and DD2 codes, retrieve new value if changed
    For (Account a : Trigger.New){
        
        IF(Trigger.isInsert && Trigger.isBefore && a.RecordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Account').getRecordTypeId()){
            
            a.Industry_Code_Description__c = DD1Values.get(a.DD1_Industry_Business_Code__c);
            a.Business_Unit_Level_2__c  = DD2Values.get(a.DD2_Industry_Business_Code__c);
            
        }   
        
        IF(Trigger.isUpdate && Trigger.isBefore && a.RecordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Account').getRecordTypeId()){
            
            IF (a.DD1_Industry_Business_Code__c != Trigger.OldMap.get(a.Id).DD1_Industry_Business_Code__c){
                a.Industry_Code_Description__c = DD1Values.get(a.DD1_Industry_Business_Code__c);
            }
            IF (a.DD2_Industry_Business_Code__c != Trigger.OldMap.get(a.Id).DD2_Industry_Business_Code__c){
                a.Business_Unit_Level_2__c  = DD2Values.get(a.DD2_Industry_Business_Code__c);
            }
            
        }
    }
    
}
Here is my test class:
 
@isTest
public class Account_BU_Update_Test {
    
    
    
    static testmethod void testall(){
        ClsTestCustomSettingHelper.getAllSettings();
        ClsTestCustomSettingHelper.getPMV_Sales_Stage_Setting();
        ChannelinsightData_test.ChannelinsightData_test();
        ClsTestCustomSettingHelper.getTrigger_Configuration();
        
        RecordType rt = ClsTestHelp.createTestRecordType8();
        Account acc2 = ClsTestHelp.createTestAccounts();
        acc2.RecordTypeId =rt.Id;
        acc2.Account_Manager__c = UserInfo.getUserId();
        acc2.DD1_Industry_Business_Code__c = '001';
        acc2.DD2_Industry_Business_Code__c = '105';
        acc2.Name = 'Test account Michael';
        insert acc2;
        
        
        Test.startTest();
        
        acc2=[Select id, Industry_Code_Description__c, Business_Unit_Level_2__c FROM Account WHERE ID =:acc2.Id];
        System.assertEquals('Automotive', acc2.Industry_Code_Description__c);
        
        Test.stopTest();
        
    }
    
    
}
I need to include a few helper classes at the beginning and I am also creating a new account record with a helper class.
If I don't do a system assert, code coverage is fine, but I don't get why the system.assert would return:

System.AssertException: Assertion Failed: Expected: Automotive, Actual: null

I create a test record, insert it, query it again, including the field Industry_Code_Description__c, but the value for it continues to be null.
I verified that the account has the correct record type for the trigger and if I do the same test in the UI it works without any problems.
For the test data above I set the DD1_Industry_Business_code to '001' and in my custom setting the corresponing value would be 'Automotive'.

Any ideas where I might miss something ?

Thanks.
 
When the system automatically does something, why does the history show it was a user in the system?  If something is automatically done by the system, can we have the User read something like “CRM” or “System.”

Please guide !

Thanks in advance
 
 
Hi All,
I have one question,Is that possible to display Reminder column in My Task related list under Home?
Please suggest me,can we customize the related list under Home?  
Thanks in advance!!
Hello,

I tried to code my test trigger apex class but I have an error with the code coverage.
Here is my trigger :
 
trigger CreateBillingCaseAfterRegistration on Case (after update) {

if(trigger.new[0].Status=='closed' && (trigger.old[0].Status<>'closed') && (trigger.new[0].Subject=='New hotel : Availpro Registration') && (trigger.new[0].Opportunity_Case__c != null))
                {
                
                                List<Features__c> Feat =new List<Features__c>();
                                List<Existing_feature__c> Existing =new List<Existing_feature__c>();
                                List<Quote> Quo=new List<Quote>();
                                List<Case> CaseOpp =new List<Case>();
                                
                                case c1=new case(
                                        Subject='New hotel : Kick off',
                                        OwnerId='00Gw0000002lubt', 
                                        Opportunity_Case__c = trigger.new[0].Opportunity_Case__c,
                                        Alfred_Scope__c = 'Configuration - Hotel',
                                        Subject__c = 'New Hotel',
                                        Type = 'Action Request', 
                                        Training_type__c = 'Kick-Off Call',
                                        Kick_off_date__c=trigger.new[0].Kick_off_date__c, 
                                        Origin ='Automatic case',                                     
                                        AccountId = trigger.new[0].AccountId,
                                        CurrencyIsoCode = trigger.new[0].CurrencyIsoCode);
                                        CaseOpp.add(c1);
                                     
                              insert CaseOpp;
                              
                               case c2=new case(
                                        Subject='New hotel : Add / Modify Channel : Start Date Invoicing',
                                        OwnerId='00G20000001HboH',
                                        AccountId = trigger.new[0].AccountId,
                                        Opportunity_Case__c = trigger.new[0].Opportunity_Case__c,
                                        Accounting_Status__c = 'Démarrage facturation',
                                        Accounting_request_type__c = 'Paramétrage module facturation',
                                        Alfred_Scope__c = 'Billing',
                                        Subject__c = 'Accounting',
                                        Type = 'Action Request',
                                        Origin ='Automatic case',
                                        Accounting_first_invoicing_date__c = trigger.new[0].Opportunity_Start_Date__c.addDays(61),
                                        CurrencyIsoCode = trigger.new[0].CurrencyIsoCode);
                                        insert c2;
                                
                                
                                for(OpportunityLineItem OLI : [SELECT PricebookEntry.Product2.Name, Billing_Type__c, CurrencyIsoCode, UnitPrice,TotalPrice,Number_Of_Revenue_Installments__c, ServiceDate from OpportunityLineItem where opportunityId =: trigger.new[0].Opportunity_Case__c AND ((PricebookEntry.Product2.Name LIKE '%Set Up Fee%') OR (PricebookEntry.Product2.Name LIKE '%training%'))])
                                     {
                                    
                                        String ProductName= String.ValueOf(OLI.PricebookEntry.Product2.Name);
                                        
                                        if(OLI.Billing_Type__c=='Monthly'){
                                        case c3=new case(
                                        Subject='New hotel : Invoicing :'+' '+ProductName,
                                        OwnerId='00G20000001HboH', 
                                        AccountId = trigger.new[0].AccountId, 
                                        Opportunity_Case__c=trigger.new[0].Opportunity_Case__c,
                                        Accounting_first_invoicing_date__c = OLI.ServiceDate, 
                                        Accounting_Status__c = 'Démarrage facturation',
                                        Accounting_request_type__c = 'Paramétrage module facturation',
                                        Alfred_Scope__c = 'Billing',
                                        Subject__c = 'Accounting',
                                        Type = 'Action Request',
                                        Origin ='Automatic case',
                                        Accounting_Billing_Type__c = OLI.Billing_Type__c,
                                        Amount__c = (OLI.TotalPrice)/OLI.Number_Of_Revenue_Installments__c,
                                        CurrencyIsoCode = OLI.CurrencyIsoCode);
                                        
                                        insert c3;
                                        }
                                        
                                        else{
                                        case c3=new case(
                                        Subject='New hotel : Invoicing :'+' '+ProductName,
                                        OwnerId='00G20000001HboH', 
                                        AccountId = trigger.new[0].AccountId,
                                        Opportunity_Case__c=trigger.new[0].Opportunity_Case__c,
                                        Accounting_first_invoicing_date__c = OLI.ServiceDate, 
                                        Accounting_Status__c = 'Facturation Set-up fees',
                                        Accounting_request_type__c = 'Paramétrage module facturation',
                                        Alfred_Scope__c = 'Billing',
                                        Subject__c = 'Accounting',
                                        Type = 'Action Request',
                                        Origin ='Automatic case',
                                        Accounting_Billing_Type__c = OLI.Billing_Type__c,
                                        Amount__c = OLI.TotalPrice,
                                        CurrencyIsoCode = OLI.CurrencyIsoCode);
                                        
                                        insert c3;
                                        }
                                
                                        
                                        
                                for(Existing_feature__c EXF: [SELECT Name, FeatureId__c, Product__c from Existing_feature__c where Product__c =: OLI.PricebookEntry.Product2Id])
                                     {
                                        String FeatureName= String.ValueOf(EXF.Name);
                                        Features__c  f1=new Features__c(
                                        Name = FeatureName,
                                        Feature_Id__c = string.valueof(EXF.FeatureId__c),
                                        To_be_invoiced__c = true,
                                        Date__c = datetime.now(),
                                        Account__c = trigger.new[0].AccountId);
                                        
                                        Feat.add(f1); 
                                     }
                                     
                                     }

                                insert Feat;

                }
}
And here my test class:
 
@isTest
private class TestCreateBillingCaseonCase {

    @isTest static void TestCreateBillingCaseonCaseWithOpportunity2() {
        // Test data setup
        // Create an account with an opportunity, and then try to delete it
       
        Opportunity opp = new Opportunity(Name='Opportunity TEST',
                                       StageName='Prospecting',
                                       AccountId='0012500000e1oU4',
                                       Starting_date__c=date.Today(),
                                       CloseDate=System.today().addMonths(1)
                                       );
        insert opp;
        
        OpportunityLineItem OLI = new OpportunityLineItem (UnitPrice=300,opportunityId = opp.Id,Quantity=1,PricebookEntryId='01uw000000rrJ5F');     
        insert OLI;          
        
        Quote QUOT = new Quote (Name='TEST',BillingPostalCode = '75009' ,BillingCountry = 'France' ,ContactId='0032500000ZL882',Unit_price_ex_VAT_per_room_booked__c=2,OpportunityId=opp.Id);
        insert QUOT;
        
        opp.SyncedQuoteId=QUOT.Id;
        opp.StageName='Closed Won';
        update opp;

        Case ca = new Case(Subject='New hotel : Availpro Registration',AccountId = opp.AccountId, Status ='in progress',Opportunity_Case__c = opp.Id);
        insert ca;     
        
        // Perform test
        Test.startTest(); 
        
        ca.Status='Closed';
        update ca;

        Test.stopTest();
    }
    
}
My test code is okay up to the for loop but I can't enter in for loop.
For information, My pricebookentry contain "Set up fee" in the product name.

Thanks for your help
Thomas
I need to store zipcode and need to check whether zipcode entered by user is valid or not. How can i achevie it ?
  EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email'];


with out calling like this how to  give standar template to present mail update progrm


help me in this prgrm

 
trigger SendEmailToAccount on Contact (after insert,after update) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isInsert )
        { 
           
            HelperContactTrigger.sendEmail(trigger.new);
        }
    }
        if(trigger.isAfter && trigger.isUpdate )
        {           
         HelperContactTrigger.sendEmailafter(trigger.new);
        }
}
 
public with sharing class HelperContactTrigger {
    public static List<Contact> sendEmail(List<Contact>Contacts)
    {
     
        
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();   
        
        for(Contact con : Contacts)
        {
         
            if(con.AccountId != null && con.Email != null){

                                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

              
                singleMail.setTargetObjectId(con.Id);
                singleMail.setSaveAsActivity(false);
     

singleMail.setHtmlBody('Your record:<b> ' + case.Id +' </b>has been created.<p>');
            
                emails.add(singleMail);
            }
        }
           
        Messaging.sendEmail(emails);

        return Contacts;          
        
    }

    public static List<Contact> sendEmailafter(List<Contact>Contacts)
    {
        
               List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();   
        
        for(Contact con : Contacts)
        { 
         
            if(con.AccountId != null && con.Email != null){

               
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

               
                singleMail.setTargetObjectId(con.Id);

                singleMail.setSaveAsActivity(false);

 singleMail.setHtmlBody('Your record:<b> ' + case.Id +' </b>has been updated.<p>');
              
               

                emails.add(singleMail);
            }
         }
           
        Messaging.sendEmail(emails);

        return Contacts;          
        }
    }

 

Hi,

We have added additional logic to an aex class on our Salesforce - the logic is applied to a custom object called Registration__c.

When you create a registration, the system will go through a number of conditions and will create a record called Credit - only if sertian criteria is met.
When we test this on our sandboxes, it works perfectly but when we attempt to register a site on production:
"Insert failed. First exception on row 0; first error: TOO_MANY_ENUM_VALUE, Credit Risk Reason: too many items selected: 18517 [Credit_Risk_Reason__c}"

Below is the code which causes the issue:
    listregQry2=[Select High_Risk_Email__c, High_Risk_Phone_Number__c from High_Risk__c]                           
                if(listregQry!=null){
                    for(Registrations__c r:listregQry){
                        String CreditComReason='';
                        if(sitenames==null||!sitenames.contains(r.site__r.name)){
                            Credit_Committee__c CCobj = new Credit_Committee__c(status__c='Referred');
                            CCobj.Comments_For_Credit_Committee__c=r.Comments_For_Credit_Committee__c;
                            sitenames.add(r.site__r.name);
                            if(listregQry2!=null){                               
                                for(Bad_Debt_Data__c r1:listregQry2){                                                                      
                                    if(r1.High_Risk_Email__c == r.site__r.contact__r.email)  {                                     
                                        System.debug('high risk email');
                                        CreditComReason=CreditComReason+'High Risk Email Found;';
                                    }
                                }
                               
                                if(r.site__r.contact__r.Phone != NULL){
                                    for(Bad_Debt_Data__c r2:listregQry2){
                            if(r2.High_Risk_Phone_Number__c == r.site__r.contact__r.Phone){ 
                                System.debug('high risk contact');
                                CreditComReason=CreditComReason+'High Risk Phone Number Found;';
                            }
                            }
                            }
                        }

Does anyone know what is causing this issue? Any ideas on how to resolve?

Any help is much appreciated.

Regards,
RadDude89

Hi,

I am running into some issues when running a test class in which I do a system.assert for a trigger on accounts I have written.
The trigger is relatively simple, it checks two fields on the account record and if changed or if a new account is created, it populates two other fields with corresponding values that I retrieve from a custom setting.

The trigger works fine when I test it in the UI, here is the code:
 
trigger BU_Update on Account (before insert, before update) {
    
    
    Map<String, String> DD1Values = new Map<String, String>(); //map to hold values from DD1 Custom Setting
    For(DD1_Definition__c dd1 : [SELECT DD1_Code__c, DD1_Business_Unit__c FROM DD1_Definition__c]){
        DD1Values.put(dd1.DD1_Code__c, dd1.DD1_Business_Unit__c);
    }
    Map<String, String> DD2Values = new Map<String, String>(); // map to hold values from DD2 Custom Setting
    For(DD2_Definition__c dd2 : [SELECT DD2_Code__c, DD2_Business_Unit__c FROM DD2_Definition__c]){
        DD2Values.put(dd2.DD2_Code__c, dd2.DD2_Business_Unit__c);
    }
    
    //Compare old and new values for DD1 and DD2 codes, retrieve new value if changed
    For (Account a : Trigger.New){
        
        IF(Trigger.isInsert && Trigger.isBefore && a.RecordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Account').getRecordTypeId()){
            
            a.Industry_Code_Description__c = DD1Values.get(a.DD1_Industry_Business_Code__c);
            a.Business_Unit_Level_2__c  = DD2Values.get(a.DD2_Industry_Business_Code__c);
            
        }   
        
        IF(Trigger.isUpdate && Trigger.isBefore && a.RecordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Account').getRecordTypeId()){
            
            IF (a.DD1_Industry_Business_Code__c != Trigger.OldMap.get(a.Id).DD1_Industry_Business_Code__c){
                a.Industry_Code_Description__c = DD1Values.get(a.DD1_Industry_Business_Code__c);
            }
            IF (a.DD2_Industry_Business_Code__c != Trigger.OldMap.get(a.Id).DD2_Industry_Business_Code__c){
                a.Business_Unit_Level_2__c  = DD2Values.get(a.DD2_Industry_Business_Code__c);
            }
            
        }
    }
    
}
Here is my test class:
 
@isTest
public class Account_BU_Update_Test {
    
    
    
    static testmethod void testall(){
        ClsTestCustomSettingHelper.getAllSettings();
        ClsTestCustomSettingHelper.getPMV_Sales_Stage_Setting();
        ChannelinsightData_test.ChannelinsightData_test();
        ClsTestCustomSettingHelper.getTrigger_Configuration();
        
        RecordType rt = ClsTestHelp.createTestRecordType8();
        Account acc2 = ClsTestHelp.createTestAccounts();
        acc2.RecordTypeId =rt.Id;
        acc2.Account_Manager__c = UserInfo.getUserId();
        acc2.DD1_Industry_Business_Code__c = '001';
        acc2.DD2_Industry_Business_Code__c = '105';
        acc2.Name = 'Test account Michael';
        insert acc2;
        
        
        Test.startTest();
        
        acc2=[Select id, Industry_Code_Description__c, Business_Unit_Level_2__c FROM Account WHERE ID =:acc2.Id];
        System.assertEquals('Automotive', acc2.Industry_Code_Description__c);
        
        Test.stopTest();
        
    }
    
    
}
I need to include a few helper classes at the beginning and I am also creating a new account record with a helper class.
If I don't do a system assert, code coverage is fine, but I don't get why the system.assert would return:

System.AssertException: Assertion Failed: Expected: Automotive, Actual: null

I create a test record, insert it, query it again, including the field Industry_Code_Description__c, but the value for it continues to be null.
I verified that the account has the correct record type for the trigger and if I do the same test in the UI it works without any problems.
For the test data above I set the DD1_Industry_Business_code to '001' and in my custom setting the corresponing value would be 'Automotive'.

Any ideas where I might miss something ?

Thanks.
 
public class practice {
    list<contact> c;
    list<contact> c1;
    list<contact> c2;
    list<contact> c3;
    list<contact> c4;
    list<contact> c5;
    public practice(){
         c=new list<contact>();
    c1=new list<contact>();
    c2=new list<contact>();
    c3=new list<contact>();
    c4=new list<contact>();
    c5=new list<contact>();
    public void call(){
        c=[select id,lastname from contact];
            if(c.size()!=0)
                for(integer i=0;i<=c.size();i++){
                    for(integer j=0;j<2;j++){
                    c1=c.get(j);
                        c5.add(c1);
                       }
                    for(integer j=2;j<4;j++){
                    c2=c.get(j);
                        c5.add(c2);
                       }
                    for(integer j=4;j<6;j++){
                    c3=c.get(j);
                        c5.add(c3);
                       }
                    for(integer j=6;j<100;j++){
                    c4=c.get(j);
                        c5.add(c4);
                       }
                    
                }
                system.debug(c);
        system.debug(c1);
        system.debug(c2);
        system.debug(c3);
        system.debug(c4);
        system.debug(c5);
            }
        }
}
    
ERROR:expecting a semi-colon, found '('   in line 15
        
        

 
Hi Everyone,

I have a vf page that adds multiple child records to an object.

I have a controller for this that can add/delete rows etc.

What I want to do is update a text field with some predetermined text based on the picklist value from the vf page.
for example

PICKLIST COLUMN                  DATE COLUMN                  TEXT COLUMN
PICKLIST VALUE 1                            ---                                       ---
PICKLIST VALUE 2                            ---                                       ---

On insert I want to add "Description related to picklist value 1" into the text column for the picklist value 1 row and "Description related to picklist value 2" into the other.

There is no maximum number of rows.

There are 94 different picklist values with descriptions.

I'm guessing I would hold all the description values in the controller some how and then use the picklist value to reference them.

Just not sure how.

This is my vf page and controller so far:
<apex:page controller="AddingAssessmentsController">
    <style>
        .homeTab .pageTitleIcon, .individualPalette .homeBlock .pageTitleIcon
        {
            background-position: initial;
            background-image: url('/img/icon/wrench32.png');
        }
    </style>
    
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Assessments"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!AssessmentList}" var="asst">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertAsstRow}"/>
                </apex:facet>
                <apex:column headerValue="Code">
                    <apex:inputField value="{!asst.Code__c}" required="true"/>
                </apex:column>
                <apex:column headerValue="Last Centre Date">
                    <apex:inputField value="{!asst.LastCentreDate__c}" id="LastCentreDate"/>
                </apex:column>  
                <apex:column headerValue="Date of Tech Review">
                    <apex:inputField value="{!asst.DateofTechReview__c}" id="DateOfTechReview"/>
                </apex:column>
                <apex:column headerValue="Date Received By Cert Office">
                    <apex:inputField value="{!asst.Date_Received_By_Cert_Office__c}" id="Date_Received_By_Cert_Office"/>
                </apex:column>
                <apex:column headerValue="Assessor">
                    <apex:inputField value="{!asst.Assessor__c}" id="Assessor"/>
                </apex:column>
                <apex:column headerValue="Verifier">
                    <apex:inputField value="{!asst.Verifier__c}" id="Verifier"/>
                </apex:column>
                <apex:column headerValue="Photo Scanned">
                    <apex:inputcheckbox value="{!asst.Photo_Scanned__c}" id="photoscanned" selected="true"/>
                </apex:column>
                <apex:column headerValue="Photo Scan date">
                    <apex:inputfield value="{!asst.Photo_Scan_Date__c}" id="photo_scan_date"/>
                </apex:column>
                <apex:column headerValue="Fastrack">
                    <apex:inputcheckbox value="{!asst.Fastrack__c}" id="Fastrack"/>
                </apex:column>
                <apex:column headerValue="MOT Cert">
                    <apex:inputcheckbox value="{!asst.MOT_Cert__c}" id="Mot_cert"/>
                </apex:column>
                <apex:column headerValue="Pass?">
                    <apex:inputcheckbox value="{!asst.Pass__c}" id="pass" selected="true"/>
                </apex:column>
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delAsstRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertAssessments}"/>
                <apex:commandButton value="Back" action="{!cancelAssessments}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class AddingAssessmentsController {
    Id candId;
    Id centreId;
    
    public List<Assessment__c> AssessmentList {get;set;}
    public Integer rowNum{get;set;}
    
    //Add initial Assessment row
    public AddingAssessmentsController(){
        candId = ApexPages.currentPage().getParameters().get('candId');
        centreId = ApexPages.currentPage().getParameters().get('centreId');
        AssessmentList = new List<Assessment__c>();
        AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true, Accredited_Centre__c=centreId));
    }
    
    
        //Insert AssessmentList and redirect
        public PageReference insertAssessments(){
            insert AssessmentList;
			PageReference reRender = new PageReference('/'+candId);
			reRender.setRedirect(true);
			return reRender;
    }
    
	//Cancel Assessment and redirect page
    public PageReference cancelAssessments(){
        PageReference reRender = new PageReference('/'+candId);
        reRender.setRedirect(true);
        return reRender;
    }
    
    //Insert Assessment Row
    public void insertAsstRow(){
        if(AssessmentList.Size()>0){
        Assessment__c tmpAssessment = AssessmentList.get(0);
        AssessmentList.add(new Assessment__c(Candidate__c=candId,
                                             Verifier__c=tmpAssessment.Verifier__c,
                                             Assessor__c=tmpAssessment.Assessor__c,
                                             LastCentreDate__c=tmpAssessment.LastCentreDate__c,
                                             DateofTechReview__c=tmpAssessment.DateofTechReview__c,
                                             Date_Received_By_Cert_Office__c=tmpAssessment.Date_Received_By_Cert_Office__c,
                                             Photo_Scanned__c=tmpAssessment.Photo_Scanned__c,
                                             Photo_Scan_Date__c=tmpAssessment.Photo_Scan_Date__c,
                                             Fastrack__c=tmpAssessment.Fastrack__c,
                                             MOT_Cert__c=tmpAssessment.MOT_Cert__c,
                                             Pass__c=tmpAssessment.Pass__c,
                                             Accredited_Centre__c=centreId
                                            ));
    }
        else AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true, Accredited_Centre__c=centreId));
    }
    
    //Delete Assessment Row
    public void delAsstRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        AssessmentList.remove(rowNum);
    }
}

Thanks for your help.