• Derek Patrick Daya
  • NEWBIE
  • 50 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 19
    Replies

Hello Everyone,

I need your assistance to an issue I am facing right now. I've created a VF page that allows users to send an SMS message to Campaign Members. The page has a function that allows users to select a template to use and it's working very well! Unfortunately when the users did not select a template and decided to just type in the message they get the error (Invalid id: Error is in expression '{!processSelected}' in component <apex:commandButton> in page ddmasssms: External entry point). I've looked into it and most of the information available pertains to not "!=" so I changed all <> to != but still receive the same error.

Here is the code to display the list of templates:-

public List<SelectOption> getListOftemplates(){
           List<SelectOption> TemplateOptionList = new List<SelectOption>();
           TemplateOptionList .add(new SelectOption( ' ' ,'--Select--'));
           for(SMS_Data_Template__c sdl: templatemap.values())
           {
                      TemplateOptionList .add(new SelectOption(sdl.id , sdl.Name));
           }
          return TemplateOptionList ;
    }
    public pagereference gettemplate(){
          sdl = [select id,Text_Message__c from SMS_Data_Template__c where id=:selectedtemplateId];
          return null;

----------

Here is the code to place the message on the VF page:

public void updatemessage(){
        sd2.Text_Message__c = templatemap.get(selectedtemplateId).Text_Message__c;
    }

------------
Here is the code to replace the merge fields with correct values:-

if(templatemap.get(selectedtemplateId) != null) {
                            sd.Text_Message__c = templatemap.get(selectedtemplateId).Text_Message__c.replace('{!FirstName}', cm.Firstname==null?'':cm.Firstname).replace('{!LastName}',  cm.Lastname==null?'':cm.Lastname).replace('{!SMS_Mobile_Number__c}', cm.SMS_Mobile_Number__c==null?'':cm.SMS_Mobile_Number__c).replace('{!email}', cm.email==null?'':cm.email);
                            sd2.Text_Message__c = templatemap.get(selectedtemplateId).Text_Message__c.replace('{!FirstName}', cm.Firstname==null?'':cm.Firstname).replace('{!LastName}', cm.Lastname==null?'':cm.Lastname).replace('{!SMS_Mobile_Number__c}', cm.SMS_Mobile_Number__c==null?'':cm.SMS_Mobile_Number__c).replace('{!email}', cm.email==null?'':cm.email);
                        } else {
                        sd.Text_Message__c = sd2.Text_Message__c;

Thank you so much in advance for your help.

Hi Eveyone,

I am currently working on an addition requirements and I could not get it to work. Can anyone give me any idea how to achieve below requirement?

Object1 = SMS_Data__c
Object2 = SMS_Data_Template__c

I created a VF page for SMS Data, it has a field called Text_Message__c. Now I added a drop down list on that VF page of all active SMS_Data_Template__c records but for some reason it does not rerender the field.

Here is the suppossedly end result.

SMS_Data__c.Text_Message__c = SMS_Data_Template__c.Text_Message__c;

Please see my codes below:

<!-- Class -->
public SMS_Data_Template__c sdl{get;set;}
public String selectedtemplateId{get;set;}


public List<SelectOption> getListOftemplates(){
           List<SMS_Data_Template__c> TemplateList = [select id,Name,Text_Message__c from SMS_Data_Template__c WHERE Active__c=True] ;
           System.debug('Templates'+TemplateList.size());
           List<SelectOption> TemplateOptionList = new List<SelectOption>();
           TemplateOptionList .add(new SelectOption( ' ' ,'--Select--'));
           for(SMS_Data_Template__c sdl: TemplateList )
           {
                      TemplateOptionList .add(new SelectOption(sdl.id , sdl.Name));
           }
          return TemplateOptionList ;
    }
    public pagereference gettemplate(){
          sdl = [select id,Text_Message__c from SMS_Data_Template__c where id=:selectedtemplateId];
          return null;


<!-- Visualforce Page -->
<apex:pageBlockSectionItem >
<apex:outputlabel value="Select a Template" for="SelectTemplate"/>
<apex:actionRegion >
<apex:selectList value="{!selectedtemplateId}" size="1" multiselect="false" id="SelectTemplate">
<apex:selectOptions value="{!ListOfTemplates}"/>
<apex:actionSupport event="onchange" rerender="Template1" />
 </apex:selectList>
</apex:actionRegion>
</apex:pageBlockSectionItem>

<apex:pageBlockSection columns="1"  collapsible="true" id="Template1" rendered="true">
<apex:inputtextarea rendered="{!sdl<>null}" value="{!sd.Text_Message__c==sdl.Text_Message__c}" style="width: 600px;"/>
<apex:inputtextarea rendered="{!sdl<>null}" value="{!sdl.Text_Message__c}" style="width: 600px;"/>
 </apex:pageBlockSection>

 

Both of the inputtextarea returns null even i have already selected a SMS Data Template record.

 

Thank you in advance to anyone who can point me to the right direction.

Hi all,

I have created a VF page with a form that allow users to create a record in Salesforce, it 100% working but I've received couple of feedbacks from my users that the form is too long.

To make it short I need to divide the form into different pages but what I wanted to know is if its possible for me to use pagination on the form. 

Any ideas are welcome on how to make a form short without having to create multiple Visualforce pages as I am not sure how would that work without losing the values inputted from the previous page.

Thank you!

Hi Everyone,

I am currently facing an issue on a VF page I've created which uses a Javascript to count number of characters on a inputtextarea as users type in. This works very well but with the new requirements to improve the VF page wherein there has to be different character limit per country I was force to use render function. Before the section where the textarea field is located the counter works well but right after it gets rerendered the javascript stopped working.

I've inspected the page before the render and after the render, and this part of the code went missing after rerendering.
<div class="jqEasyCounterMsg" style="font-size: 12px; font-family: Arial; color: rgb(0, 0, 0); text-align: right; width: 600px; opacity: 0;">Characters: 0/210</div>

Thank you in advance for any inputs!

Hi All,

Hope someone could help me! I have written a test class but it only has 25% code coverage and upon checking on Developer Console, the part of my class that is not yet covered is the function that makes a multi-select picklist field appear as a checkbox on my visualforce page. As of now I don't have any idea on how I can add multiselect picklist values to display and get the selected value on the test class. Can someone please help me on this? Thank you!

Test Class: -
             PageReference pageRef2 = Page.DD_SurveyFormENNoimeTYPage;
            Test.setCurrentPage(pageRef2);
            
            //i have 2 more landing pages that gets selected based on the value placed on language__c hidden field on VF page
            //how do i add an if to set pageref2 value based on the value on language__c
                     
            PageReference pageRef1 = Page.DD_SurveyFormEN_Noime;
            Test.setCurrentPage(pageRef1);
            ApexPages.currentPage().getParameters().put('id',c.id);
            
            ApexPages.StandardController dc = new ApexPages.StandardController(sf);
            DerekSurveyFormNoime JobExCon = new DerekSurveyFormNoime(dc);
            
            //how to display here the options for multiselect picklist and return selected option
            JobExCon.savesf();

 

Here is the part of my class that converts multiselect picklist to a checkbox: -

public List<SelectOption> MPOptions {
     get {
       List<SelectOption> options = new List<SelectOption>();
       for( Schema.PicklistEntry f : DD_Survey_Form__c.What_is_your_preferred_commucation__c.getDescribe().getPicklistValues()) {
         options.add(new SelectOption(f.getValue(), f.getLabel()));
        } 
       return options;
     }  
     set;
    }
    
    public String[] MPItems { 
     get {
        String[] selected = new List<String>();
        List<SelectOption> sos = this.MPOptions;
        for(SelectOption s : sos) {
        if (this.sf.What_is_your_preferred_commucation__c !=null && this.sf.What_is_your_preferred_commucation__c.contains(s.getValue()))
           selected.add(s.getValue());
        }
        return selected;
     }public set {
        String selectedCheckBox = '';
        for(String s : value) {
         if (selectedCheckBox == '') 
           selectedCheckBox += s;
         else selectedCheckBox += ';' + s;
        }
        sf.What_is_your_preferred_commucation__c = selectedCheckBox;
     }
   } 

Hi Everyone,

I am currently facing difficulty on adding a new functionality in my Visualforce Page. The VF page I've created is working as expected and it display multi-select picklist values as checkbox. Now a new improvement has been requested where is if a value in a multi select picklist is selected/checked then it should display a text field.

I was able to make it work without converting multi-select picklist as checkbox and adding <apex:actionRegion> and <apex:actionSupport> on my visualforce page but when I convert the multi-select picklist to checkbox it did not rerendered after marking a value as checked.

Thank you everyone for your help!

I have created a VF page on Sandbox and it's working as expected, when Singapore is selected on the Country of Residence field a new field will be appearing called Work Status.

I deployed it to Live Org and when I tested it there the Work Status field do not appear when Singapore is selected on the Country of Residence.

Can anyone please help?

I followed this article and it worked perfectly on Sandbox but not on Live Org.

https://help.salesforce.com/articleView?id=000003854&r=https%3A%2F%2Fwww.google.com.ph%2F&type=1

I have a trigger that I previously deployed on my production. It has 100% code coverage and did not have any problem with any of the triggers.

Recently with the updates done by the Third Party App, started experiencing error with our custom send email button on a VF page. It produces SOQL Limit error. Upon checking debug logs, we notice that my trigger is the one causing it. Now I am trying to deactivate it but without any success.

1. Deactivated trigger on Sandbox and deploy it to prod. we received Apex Heap Size error upon deploying.
2. Tried to uncomment out all the codes in test class and trigger, I still received the same error.
3. Used Force.com IDE, downloaded the trigger and change it there to inactive then deployed to server, same error is received. Heap Size error on 3 test classes on the production.

Did anyone experience same issues before? Can any shed some other ways to deactivate that trigger?
Hi All,

I have the following codes and for some reason it's hitting SOQL Limit when another Trigger fires. I think I need to bulkify this code in order for the error not be received. Can anyone help me bulkify the codes below? Please.

    trigger DerekCountApplicantsWithActivity on AVTRRT__Job__c (before update) {
     for (AggregateResult ar : [
      Select Count(Id) numRecs, AVTRRT__Job__c jobId
      From AVTRRT__Job_Applicant__c
      Where Last_Activity_Date__c != null and AVTRRT__Job__c In :Trigger.New
      Group By AVTRRT__Job__c]) {
    
       Id jobId = (Id) ar.get('jobId');
       AVTRRT__Job__c job = Trigger.newMap.get(jobId);
       job.Number_of_Applicants_with_Activities__c = (Decimal) ar.get('numRecs');
     }
    }



The error receive when we run a debug log is:

"Trigger.DerekCountApplicantsWithActivity: line 2, column 1
18:59:34.291 (21291921315)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101

Trigger.DerekCountApplicantsWithActivity: line 2, column 1
18:59:34.292 (21292028756)|CODE_UNIT_FINISHED|DerekCountApplicantsWithActivity on Job trigger event BeforeUpdate for [a0FF000000I9dIx]
18:59:34.294 (21294614785)|DML_END|[21]
18:59:34.298 (21298582601)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101

Trigger.DerekCountApplicantsWithActivity: line 2, column 1
18:59:34.298 (21298597822)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101"


Please help!
I am new to this and I hope someone can help me with this.

What my aim is to count the number of AVTRRT__Job_Applicant__c records with a date value on Last_Activity__c field on AVTRRT__Job_Applicants__c object that is associated to AVTRRT__Job__c and place the total count on the field called Number_of_Applicants_with_Activities__c on AVTRRT__Job__c object.

I think Agrgregate SOQL is the only option I have since using the code below conflicts with another trigger as it causes continues loop.

trigger DerekRollUp on AVTRRT__Job_Applicant__c (after insert, after update, after delete, after undelete) {
Map updateJob = new Map(); Set updateJobIds = new Set();

// If we are inserting, updating, or undeleting, use the new ID values
if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)
for(AVTRRT__Job_Applicant__c applicant:Trigger.new)
updateJobIds.add(applicant.AVTRRT__Job__c);

// If we are updating, some Jobs might change, so include that as well as deletes
if(Trigger.isUpdate || Trigger.isDelete)
for(AVTRRT__Job_Applicant__c applicant:Trigger.old)
updateJobIds.add(applicant.AVTRRT__Job__c);

// Do not create a record for null field
updateJobIds.remove(null);

// Create in-memory copies for all Jobs that will be affected
for(Id JobId:updateJobIds)
updateJob.put(JobId,new AVTRRT__Job__c(id=JobId,Number_of_Applicants_with_Activities__c=0));

// Run an optimized query that looks for all Jobs that meet the if/then criteria
for(AVTRRT__Job_Applicant__c applicant:[select id,AVTRRT__Job__c from AVTRRT__Job_Applicant__c where AVTRRT__Job__r.Id in :updateJobIds and Last_Activity_Date__c !=null]) updateJob.get(applicant.AVTRRT__Job__c).Number_of_Applicants_with_Activities__c++;

// Update all the Jobs with new values.
Database.update(updateJob.values());
}
Hi All,

I have a VF template with Apex Class on our Production. I update the Apex Class on our sandbox to add a filter criteria to limit the result. unfortunately when I try to deploy it, I receive an error that says "DerekUpdateSource.updateUpdateSource(), Details: System.LimitException: AVTRRT:Too many SOQL queries: 101 (AVTRRT)".

The tricky part is DerekUpdateSource test class is not what I am deploying its a different one and that "DerekUpdateSource" is already deployed on our Production.

What I did was, I run a test on DerekUpdateSource on our Production and it gave the error "Too many SOQL queries: 101 " but on our Sandbox when I run the test it passed.

The only changes that happened on our Org recently was Target Recruit (third party app) deployed a patch update on our production to resolve a bug. After that I can no longer deploy any class that uses queries record. 

Target Recruit on our Sandbox is not yet update to the lastest patch of Target Recruit.

Is the DerekUpdateSource test class that has a problem or the recent patch of target recruit?

If its DerekUpdateSource test class, I really do not have any other ideas how to shorten this.

DerekUpdateSource Test Class:

@IsTest
public class DerekUpdateSource {

    static testmethod void updateUpdateSource(){

        AVTRRT__Config_Settings__c mycs = AVTRRT__Config_Settings__c.getValues('Default');
    if(mycs == null) 
    {
        mycs = new AVTRRT__Config_Settings__c(Name= 'Default');
        mycs.Trigger_Disable_UpdateAccountName__c = true;
        insert mycs;
    }
        Contact c = new contact();
            c.LastName = 'Test';
            c.RecordtypeID = '012A0000000v0La';
            c.AVTRRT__Source__c = null;
        insert c;
        
        AVTRRT__ETCObject__c a = new AVTRRT__ETCObject__c();
            a.AVTRRT__Name__c = 'jobsDB';
            a.AVTRRT__Candidate__c = c.id;
        insert a;        
        AVTRRT__ETCObject__c b = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'jobsDB' and AVTRRT__Candidate__c = :c.Id limit 1];
        update b;
        
        Contact c1 = new contact();
            c1.LastName = 'Test1';
            c1.RecordtypeID = '012A0000000v0La';
            c1.AVTRRT__Source__c = null;
        insert c1;
        
        AVTRRT__ETCObject__c e = new AVTRRT__ETCObject__c();
            e.AVTRRT__Name__c = 'Clyde Marine Recruitment';
            e.AVTRRT__Candidate__c = c1.id;
        insert e;
        AVTRRT__ETCObject__c f = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Clyde Marine Recruitment' and AVTRRT__Candidate__c = :c1.Id limit 1];
        update f;
        
        Contact c2 = new contact();
            c2.LastName = 'Test2';
            c2.RecordtypeID = '012A0000000v0La';
            c2.AVTRRT__Source__c = null;
        insert c2;
        
        AVTRRT__ETCObject__c h = new AVTRRT__ETCObject__c();
            h.AVTRRT__Name__c = 'Corporate Event';
            h.AVTRRT__Candidate__c = c2.id;
        insert h;
        AVTRRT__ETCObject__c f1 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Corporate Event' and AVTRRT__Candidate__c = :c2.Id limit 1];
        update f1;
        
        Contact c3 = new contact();
            c3.LastName = 'Test3';
            c3.RecordtypeID = '012A0000000v0La';
            c3.AVTRRT__Source__c = null;
        insert c3;
        
        AVTRRT__ETCObject__c k = new AVTRRT__ETCObject__c();
            k.AVTRRT__Name__c = 'e Financial Careers';
            k.AVTRRT__Candidate__c = c3.id;
        insert k;
        AVTRRT__ETCObject__c f3 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'e Financial Careers' and AVTRRT__Candidate__c = :c3.Id limit 1];
        update f3; 
        
        Contact c4 = new contact();
            c4.LastName = 'Test4';
            c4.RecordtypeID = '012A0000000v0La';
            c4.AVTRRT__Source__c = null;
        insert c4;
        
        AVTRRT__ETCObject__c n = new AVTRRT__ETCObject__c();
            n.AVTRRT__Name__c = 'Email/Mailer Application';
            n.AVTRRT__Candidate__c = c4.id;
        insert n;
        AVTRRT__ETCObject__c f4 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Email/Mailer Application' and AVTRRT__Candidate__c = :c4.Id limit 1];
        update f4;
        
        Contact c5 = new contact();
            c5.LastName = 'Test5';
            c5.RecordtypeID = '012A0000000v0La';
            c5.AVTRRT__Source__c = null;
        insert c5;
        
        AVTRRT__ETCObject__c q = new AVTRRT__ETCObject__c();
            q.AVTRRT__Name__c = 'Indeed';
            q.AVTRRT__Candidate__c = c5.id;
        insert q;
        AVTRRT__ETCObject__c f5 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Indeed' and AVTRRT__Candidate__c = :c5.Id limit 1];
        update f5;      
        
        Contact c6 = new contact();
            c6.LastName = 'Test6';
            c6.RecordtypeID = '012A0000000v0La';
            c6.AVTRRT__Source__c = null;
        insert c6;
        
        AVTRRT__ETCObject__c t = new AVTRRT__ETCObject__c();
            t.AVTRRT__Name__c = 'Jobstreet';
            t.AVTRRT__Candidate__c = c6.id;
        insert t;
        AVTRRT__ETCObject__c f6 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Jobstreet' and AVTRRT__Candidate__c = :c6.Id limit 1];
        update f6;
        
        Contact c7 = new contact();
            c7.LastName = 'Test7';
            c7.RecordtypeID = '012A0000000v0La';
            c7.AVTRRT__Source__c = null;
        insert c7;
        
        AVTRRT__ETCObject__c w = new AVTRRT__ETCObject__c();
            w.AVTRRT__Name__c = 'LinkedIn - Resourcer';
            w.AVTRRT__Candidate__c = c7.id;
        insert w;
        AVTRRT__ETCObject__c f7 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'LinkedIn - Resourcer' and AVTRRT__Candidate__c = :c7.Id limit 1];
        update f7;
        
        Contact c8 = new contact();
            c8.LastName = 'Test8';
            c8.RecordtypeID = '012A0000000v0La';
            c8.AVTRRT__Source__c = null;
        insert c8;
        
        AVTRRT__ETCObject__c a1 = new AVTRRT__ETCObject__c();
            a1.AVTRRT__Name__c = 'Linkedin Advert';
            a1.AVTRRT__Candidate__c = c8.id;
        insert a1;
        AVTRRT__ETCObject__c f8 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Linkedin Advert' and AVTRRT__Candidate__c = :c8.Id limit 1];
        update f8;  
        
        Contact c9 = new contact();
            c9.LastName = 'Test8';
            c9.RecordtypeID = '012A0000000v0La';
            c9.AVTRRT__Source__c = null;
        insert c9;
        
        AVTRRT__ETCObject__c a9 = new AVTRRT__ETCObject__c();
            a9.AVTRRT__Name__c = 'Reed';
            a9.AVTRRT__Candidate__c = c9.id;
        insert a9;
        AVTRRT__ETCObject__c f9 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Reed' and AVTRRT__Candidate__c = :c9.Id limit 1];
        update f9;
        
        Contact c10 = new contact();
            c10.LastName = 'Test10';
            c10.RecordtypeID = '012A0000000v0La';
            c10.AVTRRT__Source__c = null;
        insert c10;
        
        AVTRRT__ETCObject__c a10 = new AVTRRT__ETCObject__c();
            a10.AVTRRT__Name__c = 'Red Website';
            a10.AVTRRT__Candidate__c = c10.id;
        insert a10;
        AVTRRT__ETCObject__c f10 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Red Website' and AVTRRT__Candidate__c = :c10.Id limit 1];
        update f10;
        
        Contact c11 = new contact();
            c11.LastName = 'Test11';
            c11.RecordtypeID = '012A0000000v0La';
            c11.AVTRRT__Source__c = null;
        insert c11;
        
        AVTRRT__ETCObject__c a11 = new AVTRRT__ETCObject__c();
            a11.AVTRRT__Name__c = 'Trade Winds';
            a11.AVTRRT__Candidate__c = c11.id;
        insert a11;
        AVTRRT__ETCObject__c f11 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Trade Winds' and AVTRRT__Candidate__c = :c11.Id limit 1];
        update f11;
}
}
I am receiving this error on my test class which I do not understand why it occurred as it's working before I added a new function to it.

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, DerekUpdateResumeSource: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.DerekUpdateResumeSource: line 41, column 1: []

Stack Trace Class.DerekUpdateSource.updateUpdateSource: line 139, column 1

==========

Original Trigger without Error:

@IsTest
public class DerekUpdateSource {

    static testmethod void updateUpdateSource(){

        AVTRRT__Config_Settings__c mycs = AVTRRT__Config_Settings__c.getValues('Default');
    if(mycs == null)
    {
        mycs = new AVTRRT__Config_Settings__c(Name= 'Default');
        mycs.Trigger_Disable_UpdateAccountName__c = true;
        insert mycs;
    }
        Contact c = new contact();
            c.LastName = 'Test';
            c.RecordtypeID = '012A0000000v0La';
            c.AVTRRT__Source__c = null;
        insert c;
       
        AVTRRT__ETCObject__c a = new AVTRRT__ETCObject__c();
            a.AVTRRT__Name__c = 'jobsDB';
            a.AVTRRT__Candidate__c = c.id;
        insert a;       
        AVTRRT__ETCObject__c b = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'jobsDB' and AVTRRT__Candidate__c = :c.Id limit 1];
        update b;

        Contact c1 = new contact();
            c1.LastName = 'Test1';
            c1.RecordtypeID = '012A0000000v0La';
            c1.AVTRRT__Source__c = null;
        insert c1;
       
        AVTRRT__ETCObject__c e = new AVTRRT__ETCObject__c();
            e.AVTRRT__Name__c = 'Clyde Marine Recruitment';
            e.AVTRRT__Candidate__c = c1.id;
        insert e;
        AVTRRT__ETCObject__c f = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Clyde Marine Recruitment' and AVTRRT__Candidate__c = :c1.Id limit 1];
        update f;
       
        Contact c2 = new contact();
            c2.LastName = 'Test2';
            c2.RecordtypeID = '012A0000000v0La';
            c2.AVTRRT__Source__c = null;
        insert c2;
       
        AVTRRT__ETCObject__c h = new AVTRRT__ETCObject__c();
            h.AVTRRT__Name__c = 'Corporate Event';
            h.AVTRRT__Candidate__c = c2.id;
        insert h;
        AVTRRT__ETCObject__c f1 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Corporate Event' and AVTRRT__Candidate__c = :c2.Id limit 1];
        update f1;
       
        Contact c3 = new contact();
            c3.LastName = 'Test3';
            c3.RecordtypeID = '012A0000000v0La';
            c3.AVTRRT__Source__c = null;
        insert c3;
       
        AVTRRT__ETCObject__c k = new AVTRRT__ETCObject__c();
            k.AVTRRT__Name__c = 'e Financial Careers';
            k.AVTRRT__Candidate__c = c3.id;
        insert k;
        AVTRRT__ETCObject__c f3 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'e Financial Careers' and AVTRRT__Candidate__c = :c3.Id limit 1];
        update f3;
       
        Contact c4 = new contact();
            c4.LastName = 'Test4';
            c4.RecordtypeID = '012A0000000v0La';
            c4.AVTRRT__Source__c = null;
        insert c4;
       
        AVTRRT__ETCObject__c n = new AVTRRT__ETCObject__c();
            n.AVTRRT__Name__c = 'Head Hunt';
            n.AVTRRT__Candidate__c = c4.id;
        insert n;
        AVTRRT__ETCObject__c f4 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Head Hunt' and AVTRRT__Candidate__c = :c4.Id limit 1];
        update f4;
       
        Contact c5 = new contact();
            c5.LastName = 'Test5';
            c5.RecordtypeID = '012A0000000v0La';
            c5.AVTRRT__Source__c = null;
        insert c5;
       
        AVTRRT__ETCObject__c q = new AVTRRT__ETCObject__c();
            q.AVTRRT__Name__c = 'Indeed';
            q.AVTRRT__Candidate__c = c5.id;
        insert q;
        AVTRRT__ETCObject__c f5 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Indeed' and AVTRRT__Candidate__c = :c5.Id limit 1];
        update f5;     
       
        Contact c6 = new contact();
            c6.LastName = 'Test6';
            c6.RecordtypeID = '012A0000000v0La';
            c6.AVTRRT__Source__c = null;
        insert c6;
       
        AVTRRT__ETCObject__c t = new AVTRRT__ETCObject__c();
            t.AVTRRT__Name__c = 'Jobstreet';
            t.AVTRRT__Candidate__c = c6.id;
        insert t;
        AVTRRT__ETCObject__c f6 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Jobstreet' and AVTRRT__Candidate__c = :c6.Id limit 1];
        update f6;
       
        Contact c7 = new contact();
            c7.LastName = 'Test7';
            c7.RecordtypeID = '012A0000000v0La';
            c7.AVTRRT__Source__c = null;
        insert c7;
       
        AVTRRT__ETCObject__c w = new AVTRRT__ETCObject__c();
            w.AVTRRT__Name__c = 'LinkedIn - Resourcer';
            w.AVTRRT__Candidate__c = c7.id;
        insert w;
        AVTRRT__ETCObject__c f7 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'LinkedIn - Resourcer' and AVTRRT__Candidate__c = :c7.Id limit 1];
        update f7;
       
        Contact c8 = new contact();
            c8.LastName = 'Test8';
            c8.RecordtypeID = '012A0000000v0La';
            c8.AVTRRT__Source__c = null;
        insert c8;
       
        AVTRRT__ETCObject__c a1 = new AVTRRT__ETCObject__c();
            a1.AVTRRT__Name__c = 'Linkedin Advert';
            a1.AVTRRT__Candidate__c = c8.id;
        insert a1;
        AVTRRT__ETCObject__c f8 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Linkedin Advert' and AVTRRT__Candidate__c = :c8.Id limit 1];
        update f8;     
               
}
}

When added the code below to the above code, it gives me the error:

Contact c22 = new contact();
            c22.LastName = 'Test22';
            c22.RecordtypeID = '012A0000000v0La';
            c22.AVTRRT__Source__c = null;
        insert c22;
       
        AVTRRT__ETCObject__c a22 = new AVTRRT__ETCObject__c();
            a22.AVTRRT__Name__c = 'Red Website';
            a22.AVTRRT__Candidate__c = c22.id;
        insert a22;       
        AVTRRT__ETCObject__c b22 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Red Website' and AVTRRT__Candidate__c = :c22.Id limit 1];
        update b22;

=======

I really do not understand why the error occured as the code I added is the same as what other codes are which is working. Its a bit frustrating as I am already at 68% code coverage. I just need to add that to it to make it 75%.

I am new to do and honestly do not have any Idea what I am doing. Can anyon help me on this?

This is our process: Send a resume to NewEmailToCandidate Address and it creates a ETCObject record in salesforce. Then a existing trigger checks if there is any existing contact:

If yes and the resume source field on that contact has a value then my trigger (not created yet) should ignore it and not update it. But if it does not have a value, then the trigger should fire and update it based on the Name field in the ETCObject as it contains the value that should be place on the resume source field. 

If no contact is found then an existing trigger in our org will create a new one. My trigger (not created yet) should fire and update the record with the correct resume source based on the name of the ETCObject.

Here is the code i am using and I could not save it due to 2 errors:

1. Error: Compile Error: expecting right curly bracket, found 'else' at line 20 column 13
2. Error: a.AVTRRT__Name__c does not exist

trigger UpdateSource on AVTRRT__ETCObject__c (after insert, after update) {
   
    Map<Id, AVTRRT__ETCObject__c> ETCmap = new Map<Id,AVTRRT__ETCObject__c>();
    for(AVTRRT__ETCObject__c a:trigger.new)
    {

            ETCmap.put(a.AVTRRT__Candidate__c, a);

           
    }
    List<Contact> candidate = [Select Id, AVTRRT__Source__c from Contact WHERE ID IN:ETCmap.keyset() AND RecordtypeID = '012A0000000v0La'];
    List<Contact> ContactsToUpdate = new List<Contact>();
    for(Contact c:candidate)
    {
       If(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('jobsDB'))
       {
               c.AVTRRT__Source__c = 'JobsDB';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Clyde Marine Recruitment'))
               c.AVTRRT__Source__c = 'Clyde Marine Recruitment';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Corporate Event'))
               c.AVTRRT__Source__c = 'Corporate Event';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('e Financial Careers'))
               c.AVTRRT__Source__c = 'e Financial Careers';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Head Hunt'))
               c.AVTRRT__Source__c = 'Head Hunt';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Indeed'))
               c.AVTRRT__Source__c = 'Indeed';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Jobstreet'))
               c.AVTRRT__Source__c = 'Jobstreet';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Linked In'))
               c.AVTRRT__Source__c = 'Linked In';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Linkedin Advert'))
               c.AVTRRT__Source__c = 'Linkedin Advert';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('LinkedIn Recruiter'))
               c.AVTRRT__Source__c = 'LinkedIn Recruiter';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Oil&Gas JobSearch'))
               c.AVTRRT__Source__c = 'Oil&Gas JobSearch';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('OilCareers'))
               c.AVTRRT__Source__c = 'OilCareers';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Reed'))
               c.AVTRRT__Source__c = 'Reed';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Referrals'))
               c.AVTRRT__Source__c = 'Referrals';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('S1 Jobs'))
               c.AVTRRT__Source__c = 'S1 Jobs';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Straits Times'))
               c.AVTRRT__Source__c = 'Straits Times';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Trade Winds'))
               c.AVTRRT__Source__c = 'Trade Winds';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('UK Job Centre'))
               c.AVTRRT__Source__c = 'UK Job Centre';
           } else {
               c.AVTRRT__Source__c = 'Other';
           }
       ContactsToUpdate.add(c);
       }
    }
    update ContactsToUpdate;
}

Please help me..

Hello Everyone,

I need your assistance to an issue I am facing right now. I've created a VF page that allows users to send an SMS message to Campaign Members. The page has a function that allows users to select a template to use and it's working very well! Unfortunately when the users did not select a template and decided to just type in the message they get the error (Invalid id: Error is in expression '{!processSelected}' in component <apex:commandButton> in page ddmasssms: External entry point). I've looked into it and most of the information available pertains to not "!=" so I changed all <> to != but still receive the same error.

Here is the code to display the list of templates:-

public List<SelectOption> getListOftemplates(){
           List<SelectOption> TemplateOptionList = new List<SelectOption>();
           TemplateOptionList .add(new SelectOption( ' ' ,'--Select--'));
           for(SMS_Data_Template__c sdl: templatemap.values())
           {
                      TemplateOptionList .add(new SelectOption(sdl.id , sdl.Name));
           }
          return TemplateOptionList ;
    }
    public pagereference gettemplate(){
          sdl = [select id,Text_Message__c from SMS_Data_Template__c where id=:selectedtemplateId];
          return null;

----------

Here is the code to place the message on the VF page:

public void updatemessage(){
        sd2.Text_Message__c = templatemap.get(selectedtemplateId).Text_Message__c;
    }

------------
Here is the code to replace the merge fields with correct values:-

if(templatemap.get(selectedtemplateId) != null) {
                            sd.Text_Message__c = templatemap.get(selectedtemplateId).Text_Message__c.replace('{!FirstName}', cm.Firstname==null?'':cm.Firstname).replace('{!LastName}',  cm.Lastname==null?'':cm.Lastname).replace('{!SMS_Mobile_Number__c}', cm.SMS_Mobile_Number__c==null?'':cm.SMS_Mobile_Number__c).replace('{!email}', cm.email==null?'':cm.email);
                            sd2.Text_Message__c = templatemap.get(selectedtemplateId).Text_Message__c.replace('{!FirstName}', cm.Firstname==null?'':cm.Firstname).replace('{!LastName}', cm.Lastname==null?'':cm.Lastname).replace('{!SMS_Mobile_Number__c}', cm.SMS_Mobile_Number__c==null?'':cm.SMS_Mobile_Number__c).replace('{!email}', cm.email==null?'':cm.email);
                        } else {
                        sd.Text_Message__c = sd2.Text_Message__c;

Thank you so much in advance for your help.

Hi Eveyone,

I am currently working on an addition requirements and I could not get it to work. Can anyone give me any idea how to achieve below requirement?

Object1 = SMS_Data__c
Object2 = SMS_Data_Template__c

I created a VF page for SMS Data, it has a field called Text_Message__c. Now I added a drop down list on that VF page of all active SMS_Data_Template__c records but for some reason it does not rerender the field.

Here is the suppossedly end result.

SMS_Data__c.Text_Message__c = SMS_Data_Template__c.Text_Message__c;

Please see my codes below:

<!-- Class -->
public SMS_Data_Template__c sdl{get;set;}
public String selectedtemplateId{get;set;}


public List<SelectOption> getListOftemplates(){
           List<SMS_Data_Template__c> TemplateList = [select id,Name,Text_Message__c from SMS_Data_Template__c WHERE Active__c=True] ;
           System.debug('Templates'+TemplateList.size());
           List<SelectOption> TemplateOptionList = new List<SelectOption>();
           TemplateOptionList .add(new SelectOption( ' ' ,'--Select--'));
           for(SMS_Data_Template__c sdl: TemplateList )
           {
                      TemplateOptionList .add(new SelectOption(sdl.id , sdl.Name));
           }
          return TemplateOptionList ;
    }
    public pagereference gettemplate(){
          sdl = [select id,Text_Message__c from SMS_Data_Template__c where id=:selectedtemplateId];
          return null;


<!-- Visualforce Page -->
<apex:pageBlockSectionItem >
<apex:outputlabel value="Select a Template" for="SelectTemplate"/>
<apex:actionRegion >
<apex:selectList value="{!selectedtemplateId}" size="1" multiselect="false" id="SelectTemplate">
<apex:selectOptions value="{!ListOfTemplates}"/>
<apex:actionSupport event="onchange" rerender="Template1" />
 </apex:selectList>
</apex:actionRegion>
</apex:pageBlockSectionItem>

<apex:pageBlockSection columns="1"  collapsible="true" id="Template1" rendered="true">
<apex:inputtextarea rendered="{!sdl<>null}" value="{!sd.Text_Message__c==sdl.Text_Message__c}" style="width: 600px;"/>
<apex:inputtextarea rendered="{!sdl<>null}" value="{!sdl.Text_Message__c}" style="width: 600px;"/>
 </apex:pageBlockSection>

 

Both of the inputtextarea returns null even i have already selected a SMS Data Template record.

 

Thank you in advance to anyone who can point me to the right direction.

Hi all,

I have created a VF page with a form that allow users to create a record in Salesforce, it 100% working but I've received couple of feedbacks from my users that the form is too long.

To make it short I need to divide the form into different pages but what I wanted to know is if its possible for me to use pagination on the form. 

Any ideas are welcome on how to make a form short without having to create multiple Visualforce pages as I am not sure how would that work without losing the values inputted from the previous page.

Thank you!

Hi Everyone,

I am currently facing an issue on a VF page I've created which uses a Javascript to count number of characters on a inputtextarea as users type in. This works very well but with the new requirements to improve the VF page wherein there has to be different character limit per country I was force to use render function. Before the section where the textarea field is located the counter works well but right after it gets rerendered the javascript stopped working.

I've inspected the page before the render and after the render, and this part of the code went missing after rerendering.
<div class="jqEasyCounterMsg" style="font-size: 12px; font-family: Arial; color: rgb(0, 0, 0); text-align: right; width: 600px; opacity: 0;">Characters: 0/210</div>

Thank you in advance for any inputs!

I have created a VF page on Sandbox and it's working as expected, when Singapore is selected on the Country of Residence field a new field will be appearing called Work Status.

I deployed it to Live Org and when I tested it there the Work Status field do not appear when Singapore is selected on the Country of Residence.

Can anyone please help?

I followed this article and it worked perfectly on Sandbox but not on Live Org.

https://help.salesforce.com/articleView?id=000003854&r=https%3A%2F%2Fwww.google.com.ph%2F&type=1

I have a trigger that I previously deployed on my production. It has 100% code coverage and did not have any problem with any of the triggers.

Recently with the updates done by the Third Party App, started experiencing error with our custom send email button on a VF page. It produces SOQL Limit error. Upon checking debug logs, we notice that my trigger is the one causing it. Now I am trying to deactivate it but without any success.

1. Deactivated trigger on Sandbox and deploy it to prod. we received Apex Heap Size error upon deploying.
2. Tried to uncomment out all the codes in test class and trigger, I still received the same error.
3. Used Force.com IDE, downloaded the trigger and change it there to inactive then deployed to server, same error is received. Heap Size error on 3 test classes on the production.

Did anyone experience same issues before? Can any shed some other ways to deactivate that trigger?
Hi All,

I have the following codes and for some reason it's hitting SOQL Limit when another Trigger fires. I think I need to bulkify this code in order for the error not be received. Can anyone help me bulkify the codes below? Please.

    trigger DerekCountApplicantsWithActivity on AVTRRT__Job__c (before update) {
     for (AggregateResult ar : [
      Select Count(Id) numRecs, AVTRRT__Job__c jobId
      From AVTRRT__Job_Applicant__c
      Where Last_Activity_Date__c != null and AVTRRT__Job__c In :Trigger.New
      Group By AVTRRT__Job__c]) {
    
       Id jobId = (Id) ar.get('jobId');
       AVTRRT__Job__c job = Trigger.newMap.get(jobId);
       job.Number_of_Applicants_with_Activities__c = (Decimal) ar.get('numRecs');
     }
    }



The error receive when we run a debug log is:

"Trigger.DerekCountApplicantsWithActivity: line 2, column 1
18:59:34.291 (21291921315)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101

Trigger.DerekCountApplicantsWithActivity: line 2, column 1
18:59:34.292 (21292028756)|CODE_UNIT_FINISHED|DerekCountApplicantsWithActivity on Job trigger event BeforeUpdate for [a0FF000000I9dIx]
18:59:34.294 (21294614785)|DML_END|[21]
18:59:34.298 (21298582601)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101

Trigger.DerekCountApplicantsWithActivity: line 2, column 1
18:59:34.298 (21298597822)|FATAL_ERROR|System.LimitException: Too many SOQL queries: 101"


Please help!
I have a page detail button the is designed to execute javascript when clicked, resulting in a custom checkbox becoming marked "true" and the page refreshing/reloading.

Here is the code I am currently working with:
 
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}

//declare the varaiable that will hold all the information
var newRecords = [];

var opp = new sforce.SObject("Opportunity");
opp.Id = '{!Opportunity.Id}';
opp.Manager_Followed_Opportunity__c = '1';

//push the information through
newRecords.push(opp);

//save the change
result = sforce.connection.update([opp]);

//refresh the page
window.location.reload();

I cannot get the box to become marked true (I have already tried  changing 
opp.Manager_Followed_Opportunity__c = '1'; to = true/True/'True'/'true' with no success.)

Thank you in advance for any help you can provide!
  • December 09, 2014
  • Like
  • 0
I am receiving this error on my test class which I do not understand why it occurred as it's working before I added a new function to it.

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, DerekUpdateResumeSource: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.DerekUpdateResumeSource: line 41, column 1: []

Stack Trace Class.DerekUpdateSource.updateUpdateSource: line 139, column 1

==========

Original Trigger without Error:

@IsTest
public class DerekUpdateSource {

    static testmethod void updateUpdateSource(){

        AVTRRT__Config_Settings__c mycs = AVTRRT__Config_Settings__c.getValues('Default');
    if(mycs == null)
    {
        mycs = new AVTRRT__Config_Settings__c(Name= 'Default');
        mycs.Trigger_Disable_UpdateAccountName__c = true;
        insert mycs;
    }
        Contact c = new contact();
            c.LastName = 'Test';
            c.RecordtypeID = '012A0000000v0La';
            c.AVTRRT__Source__c = null;
        insert c;
       
        AVTRRT__ETCObject__c a = new AVTRRT__ETCObject__c();
            a.AVTRRT__Name__c = 'jobsDB';
            a.AVTRRT__Candidate__c = c.id;
        insert a;       
        AVTRRT__ETCObject__c b = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'jobsDB' and AVTRRT__Candidate__c = :c.Id limit 1];
        update b;

        Contact c1 = new contact();
            c1.LastName = 'Test1';
            c1.RecordtypeID = '012A0000000v0La';
            c1.AVTRRT__Source__c = null;
        insert c1;
       
        AVTRRT__ETCObject__c e = new AVTRRT__ETCObject__c();
            e.AVTRRT__Name__c = 'Clyde Marine Recruitment';
            e.AVTRRT__Candidate__c = c1.id;
        insert e;
        AVTRRT__ETCObject__c f = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Clyde Marine Recruitment' and AVTRRT__Candidate__c = :c1.Id limit 1];
        update f;
       
        Contact c2 = new contact();
            c2.LastName = 'Test2';
            c2.RecordtypeID = '012A0000000v0La';
            c2.AVTRRT__Source__c = null;
        insert c2;
       
        AVTRRT__ETCObject__c h = new AVTRRT__ETCObject__c();
            h.AVTRRT__Name__c = 'Corporate Event';
            h.AVTRRT__Candidate__c = c2.id;
        insert h;
        AVTRRT__ETCObject__c f1 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Corporate Event' and AVTRRT__Candidate__c = :c2.Id limit 1];
        update f1;
       
        Contact c3 = new contact();
            c3.LastName = 'Test3';
            c3.RecordtypeID = '012A0000000v0La';
            c3.AVTRRT__Source__c = null;
        insert c3;
       
        AVTRRT__ETCObject__c k = new AVTRRT__ETCObject__c();
            k.AVTRRT__Name__c = 'e Financial Careers';
            k.AVTRRT__Candidate__c = c3.id;
        insert k;
        AVTRRT__ETCObject__c f3 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'e Financial Careers' and AVTRRT__Candidate__c = :c3.Id limit 1];
        update f3;
       
        Contact c4 = new contact();
            c4.LastName = 'Test4';
            c4.RecordtypeID = '012A0000000v0La';
            c4.AVTRRT__Source__c = null;
        insert c4;
       
        AVTRRT__ETCObject__c n = new AVTRRT__ETCObject__c();
            n.AVTRRT__Name__c = 'Head Hunt';
            n.AVTRRT__Candidate__c = c4.id;
        insert n;
        AVTRRT__ETCObject__c f4 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Head Hunt' and AVTRRT__Candidate__c = :c4.Id limit 1];
        update f4;
       
        Contact c5 = new contact();
            c5.LastName = 'Test5';
            c5.RecordtypeID = '012A0000000v0La';
            c5.AVTRRT__Source__c = null;
        insert c5;
       
        AVTRRT__ETCObject__c q = new AVTRRT__ETCObject__c();
            q.AVTRRT__Name__c = 'Indeed';
            q.AVTRRT__Candidate__c = c5.id;
        insert q;
        AVTRRT__ETCObject__c f5 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Indeed' and AVTRRT__Candidate__c = :c5.Id limit 1];
        update f5;     
       
        Contact c6 = new contact();
            c6.LastName = 'Test6';
            c6.RecordtypeID = '012A0000000v0La';
            c6.AVTRRT__Source__c = null;
        insert c6;
       
        AVTRRT__ETCObject__c t = new AVTRRT__ETCObject__c();
            t.AVTRRT__Name__c = 'Jobstreet';
            t.AVTRRT__Candidate__c = c6.id;
        insert t;
        AVTRRT__ETCObject__c f6 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Jobstreet' and AVTRRT__Candidate__c = :c6.Id limit 1];
        update f6;
       
        Contact c7 = new contact();
            c7.LastName = 'Test7';
            c7.RecordtypeID = '012A0000000v0La';
            c7.AVTRRT__Source__c = null;
        insert c7;
       
        AVTRRT__ETCObject__c w = new AVTRRT__ETCObject__c();
            w.AVTRRT__Name__c = 'LinkedIn - Resourcer';
            w.AVTRRT__Candidate__c = c7.id;
        insert w;
        AVTRRT__ETCObject__c f7 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'LinkedIn - Resourcer' and AVTRRT__Candidate__c = :c7.Id limit 1];
        update f7;
       
        Contact c8 = new contact();
            c8.LastName = 'Test8';
            c8.RecordtypeID = '012A0000000v0La';
            c8.AVTRRT__Source__c = null;
        insert c8;
       
        AVTRRT__ETCObject__c a1 = new AVTRRT__ETCObject__c();
            a1.AVTRRT__Name__c = 'Linkedin Advert';
            a1.AVTRRT__Candidate__c = c8.id;
        insert a1;
        AVTRRT__ETCObject__c f8 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Linkedin Advert' and AVTRRT__Candidate__c = :c8.Id limit 1];
        update f8;     
               
}
}

When added the code below to the above code, it gives me the error:

Contact c22 = new contact();
            c22.LastName = 'Test22';
            c22.RecordtypeID = '012A0000000v0La';
            c22.AVTRRT__Source__c = null;
        insert c22;
       
        AVTRRT__ETCObject__c a22 = new AVTRRT__ETCObject__c();
            a22.AVTRRT__Name__c = 'Red Website';
            a22.AVTRRT__Candidate__c = c22.id;
        insert a22;       
        AVTRRT__ETCObject__c b22 = [Select id from AVTRRT__ETCObject__c where AVTRRT__Name__c = 'Red Website' and AVTRRT__Candidate__c = :c22.Id limit 1];
        update b22;

=======

I really do not understand why the error occured as the code I added is the same as what other codes are which is working. Its a bit frustrating as I am already at 68% code coverage. I just need to add that to it to make it 75%.

I am new to do and honestly do not have any Idea what I am doing. Can anyon help me on this?

This is our process: Send a resume to NewEmailToCandidate Address and it creates a ETCObject record in salesforce. Then a existing trigger checks if there is any existing contact:

If yes and the resume source field on that contact has a value then my trigger (not created yet) should ignore it and not update it. But if it does not have a value, then the trigger should fire and update it based on the Name field in the ETCObject as it contains the value that should be place on the resume source field. 

If no contact is found then an existing trigger in our org will create a new one. My trigger (not created yet) should fire and update the record with the correct resume source based on the name of the ETCObject.

Here is the code i am using and I could not save it due to 2 errors:

1. Error: Compile Error: expecting right curly bracket, found 'else' at line 20 column 13
2. Error: a.AVTRRT__Name__c does not exist

trigger UpdateSource on AVTRRT__ETCObject__c (after insert, after update) {
   
    Map<Id, AVTRRT__ETCObject__c> ETCmap = new Map<Id,AVTRRT__ETCObject__c>();
    for(AVTRRT__ETCObject__c a:trigger.new)
    {

            ETCmap.put(a.AVTRRT__Candidate__c, a);

           
    }
    List<Contact> candidate = [Select Id, AVTRRT__Source__c from Contact WHERE ID IN:ETCmap.keyset() AND RecordtypeID = '012A0000000v0La'];
    List<Contact> ContactsToUpdate = new List<Contact>();
    for(Contact c:candidate)
    {
       If(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('jobsDB'))
       {
               c.AVTRRT__Source__c = 'JobsDB';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Clyde Marine Recruitment'))
               c.AVTRRT__Source__c = 'Clyde Marine Recruitment';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Corporate Event'))
               c.AVTRRT__Source__c = 'Corporate Event';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('e Financial Careers'))
               c.AVTRRT__Source__c = 'e Financial Careers';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Head Hunt'))
               c.AVTRRT__Source__c = 'Head Hunt';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Indeed'))
               c.AVTRRT__Source__c = 'Indeed';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Jobstreet'))
               c.AVTRRT__Source__c = 'Jobstreet';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Linked In'))
               c.AVTRRT__Source__c = 'Linked In';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Linkedin Advert'))
               c.AVTRRT__Source__c = 'Linkedin Advert';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('LinkedIn Recruiter'))
               c.AVTRRT__Source__c = 'LinkedIn Recruiter';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Oil&Gas JobSearch'))
               c.AVTRRT__Source__c = 'Oil&Gas JobSearch';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('OilCareers'))
               c.AVTRRT__Source__c = 'OilCareers';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Reed'))
               c.AVTRRT__Source__c = 'Reed';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Referrals'))
               c.AVTRRT__Source__c = 'Referrals';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('S1 Jobs'))
               c.AVTRRT__Source__c = 'S1 Jobs';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Straits Times'))
               c.AVTRRT__Source__c = 'Straits Times';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('Trade Winds'))
               c.AVTRRT__Source__c = 'Trade Winds';
           } else if(c.AVTRRT__Source__c == '' && a.AVTRRT__Name__c.contains('UK Job Centre'))
               c.AVTRRT__Source__c = 'UK Job Centre';
           } else {
               c.AVTRRT__Source__c = 'Other';
           }
       ContactsToUpdate.add(c);
       }
    }
    update ContactsToUpdate;
}

Please help me..