• anto nirmal
  • NEWBIE
  • 315 Points
  • Member since 2015
  • Sales force Lead

  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 1
    Questions
  • 39
    Replies
Hello All!

I am using this formula to calculate the term in months from effective date to end date. Works great if the months are different. However, it appears to be adding a month if my effective and end dates are in the same month.

e.g. Effective Date: 11/23/2015
       End DAte: 11/22/2016
Calculating 13 month term.


Anyone know how I can resolve?

Data Type Formula    
Decimal Places 0    
IF(NOT(ISBLANK(Service_End_Date__c)) && NOT(ISBLANK(Service_Effective_Date__c)) 
,(((YEAR(Service_End_Date__c ) - YEAR(Service_Effective_Date__c ) - 1) *12) + (12 - MONTH(Service_Effective_Date__c) +1) + MONTH(Service_End_Date__c )) 
, null 
)
Hi All,

I have a batch class that sends an email in the finish() method whenver errors are present. The email distribution list is set up under custom settings so it can be easily adjusted without having to directly modify the code in a sandbox, turn off the batch schedule, push the new code in, and turn the schedule back on.

I'm being a bit anal about this, but I would like to see 100% code coverage for my batch class - but I'm not sure how to write it up in my test class approrpriately. 

Here's the finish method:
global void finish(Database.BatchableContext BC) {
		AsyncApexJob job = [SELECT Id, ApexClassId, JobItemsProcessed, TotalJobItems, NumberOfErrors, CreatedBy.Email
							FROM AsyncApexJob WHERE Id = :BC.getJobId()];

		if(failedUpdates > 0 || job.NumberOfErrors > 0) {
			String emailMessage = 'Batch Job TaskUpdateActivityInfo has errors. <br/><br/>'
								 +'Number of batches: ' + job.TotalJobItems + '<br/>'
								 +'Number of successful batches: ' + job.JobItemsProcessed + '<br/>'
								 +'Number of unsuccessful batches: ' + job.NumberOfErrors + '<br/>'
								 +'Number of unsucessful record updates: ' + failedUpdates + '<br/><br/>'
								 +'For more details, please review the Apex Errors tab.';

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

			//Uses custom setting to add other email addresses
			String[] toAddresses = new String[] {job.CreatedBy.email};

			Map<String, Apex_Distribution_List__c> distList = Apex_Distribution_List__c.getAll();
	        String serverhost = URL.getSalesforceBaseUrl().getHost().left(2);

	        for(Apex_Distribution_List__c record : distList.values()) {
	            //If it's a produciton environment, add only system admin emails
	            if(serverHost == 'na')
	            	if(record.System_Admin_Email__c)
	            		toAddresses.add(record.Email__c);
	            //Otherwise, only add those that are enabled for sandbox alerts
	            else
	                if(record.Enabled_for_Sandbox_Alerts__c)
	                	toAddresses.add(record.Email__c);
	        }

			mail.setToAddresses(toAddresses);
			mail.setReplyTo('kkorynta@navicure.com');
			mail.setSenderDisplayName('Salesforce Apex Batch Job Summary');
			mail.setSubject('Salesforce Batch Job Summary: Task Update Activity Info');
			mail.setHTMLBody(emailMessage);
			Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
		}
	}

These are the lines I'm not able to get coverage on:
//If it's a produciton environment, add only system admin emails
	            if(serverHost == 'na')
	            	if(record.System_Admin_Email__c)
	            		toAddresses.add(record.Email__c);
	            //Otherwise, only add those that are enabled for sandbox alerts
	            else
	                if(record.Enabled_for_Sandbox_Alerts__c)
	                	toAddresses.add(record.Email__c);


Does anyone have any suggestions on how to get coverage on this? I'm at 91% currently.

Thanks,
Kelly
Hi All,

How can i hardcode createddate(standard field) value in my trigger. PFB  code but i am getting an unexpected token error.
 
incident.Createddate>2013-19-12T11:30:40.000Z

 
  • December 14, 2015
  • Like
  • 0
Greetings, I am looking to create a formula field that compares data values. In the event that the dates don't match up. If they don't I want to create that refers the date in the account field if it is less than that in the contact field, and vice versa. 
 
IF(npo02__FirstCloseDate__c <> Account.npe01__FirstDonationDate__c,
IF(npo02__FirstCloseDate__c < Account.npe01__FirstDonationDate__c, npo02__FirstCloseDate__c,
IF(npo02__FirstCloseDate__c > Account.npe01__FirstDonationDate__c, Account.npe01__FirstDonationDate__c
,npo02__FirstCloseDate__c
)))
However, I get this error message reading Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 2.

Any thing I'm missing. Hope it helps.
 
So we like to have a time dependent email alert, for example 2 weeks before close date. The email need to send to the children records email fields, also different children would see their own data which has a link. I don't think the email template can do it. I need to have a custom apex code, but I don't know how time dependent workflow can call my apex code.
I have a custom visualforce page to create a contact record. It has some input fields like FirstName, LastName,Email,Phone to be entered. 
However,there are some permutation combination to be made to check if the entered contact already exists.
Ex: If firstname, lastname and email matches then throw an error: duplicate contact prevented.
I have written a piece of code which works fine and it does all the necessary checks. but my concern is if I deploy to production where I will have large number of contacts then it will hit the "governor limits" . Please help me in optimizing the code.

private Boolean duplicateContact() {
        Boolean error = false;
        String regExp = '[()-]';
        String replacement = PCS_UTIL_Constants.BLANK;
        String oldphone = PCS_UTIL_Constants.BLANK;
        String newphone = phone!=null ? phone.replaceAll(regExp,replacement) : PCS_UTIL_Constants.BLANK;
        for(Contact  existConList : [Select Id, firstName, lastName,phone, email from Contact limit 49000]) {
            oldphone = existConList.phone!=null? existConList.phone.replaceAll(regExp,replacement): PCS_UTIL_Constants.BLANK;

             if(((!String.isBlank(lname) && lname.equalsIgnoreCase(existConList.lastname)) &&
               ((!String.isBlank(email) && email.equalsIgnoreCase(existConList.email)) ||
               (existConList.phone!=null && newphone == oldphone)))||
               (!String.isBlank(lname) && !lname.equalsIgnoreCase(existConList.lastname))&&
                ((!String.isBlank(email) && email.equalsIgnoreCase(existConList.email))||
                (existConList.phone!=null && newphone == oldphone))){
                    error = true;
            }
        }
    
hii friends how can write soql query for this one pls suggest me..to retrieve the opportunities that are closed on friday in the years 2013and 2015hii friends how can write soql query for this one pls suggest me..
I'm trying to look for a specific product code in an Opportunity Line item.  If I find it, I'll update a flag to true on the Opportunity.  If I don't find it, I'll update the flag to false.

However, when I don't find it, the flow fails.

Is there a way to capture and handle this so I can continue to my Record update?

Things I'ved tried:
Set the variable values to null when the Opportunity Line Item record is not found.
Create a fault line in addition to the regular process line from the Record Lookup element to the Decision element.
Hallo, 

since I am new to Apex and specially this forum please dont be so hard on me. 

I am trying to get this to work: 

(Short explenation of the porpuse: When sending out a Mail with a specific Subject, the contact field "Recruiting_Status__c" should be updated on the contact related to the task (WhoId). 

Note: I tried to do include the contact to my list and update on two different ways as you may notice (last one is different), but code coverage keeps telling me somethings wrong.. 

Trigger: 
trigger RecEmailTrigger on Task (after insert) {
    List<Contact> contactsToUpdate = new List<Contact>();
    
    for(Task t : Trigger.new) {
        if (t.WhoId != null){
        
        List<Contact> Con = [SELECT Id, Name, Recruiting_Status__c 
                             FROM Contact 
                             WHERE Id = :t.WhoID];
        
        if(t.subject.equals('Email: Anfrage auf vollständige Bewerbungsunterlagen')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Requested complete set of documents'));}     
        
        else if(t.subject.equals('Email: Das AUCTUS Recruiting Erlebnis: selbständige Terminkoordination für ein erstes Vorabgespräch')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'In scheduling process for initial conversation'));}
        
        else if(t.subject.equals('Email: Das AUCTUS Recruiting Erlebnis: selbständige Terminkoordination für die CaseStudy@Home')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'In scheduling process for case study'));} 
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && (Con[0].Recruiting_Status__c.contains('preselected') || Con[0].Recruiting_Status__c.contains('Requested complete') )) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after preselection'));}  
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('initial conversation')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after initial conversation'));}  
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('case study')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after case study'));}
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('IM-interview')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after IM-interview'));}
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('partner/MD interview')) {
        Con[0].Recruiting_Status__c = 'Declined after partner interview';
        contactsToUpdate.addAll(Con);}
        
    } 
    }
     update contactsToUpdate;
}
Test Class:
@IsTest
public class TestRecEmailTrigger {

        static testmethod void insertTask() {
        
        User us = new User();
        
        us.FirstName = 'Test';
        us.LastName = 'User';
        us.Alias = 'UserTest';
        us.Email = 'samuel.schoessel@gmx.de';
        us.Username = 'samuel.schoessel@gmx.de';
        us.CommunityNickname = 'Sammy';
        us.TimeZoneSidKey = 'Europe/Berlin';
        us.LocaleSidKey = 'de_DE';
        us.EmailEncodingKey = 'UTF-8';
        us.LanguageLocaleKey = 'en_US';
        us.ProfileId = '00e24000000Mca5';
        
        insert us; 
         
        Account acc = new Account(); 
        
        acc.Name = 'Test Account';
        acc.RecordTypeId = '012240000004qdf';
        acc.OwnerId = us.Id;
        
        insert acc;
        
        Contact con = new Contact();
        
        con.LastName = 'The Sam';
        con.FirstName = 'Sammy';
        con.OwnerId = us.Id;
        con.RecordTypeId = '012240000006HOl'; 
        con.Recruiting_Status__C = 'Scheduled for initial conversation';  
        
        insert con;  
         
        Task t = New Task();
        
        t.Subject = 'vollständige Bewerbungsunterlagen';
        t.Priority = 'Normal';
        t.Status = 'Geschlossen';
        t.OwnerId = us.Id;
        t.WhoId = con.Id;
                
        insert t;
        }
    }

Back to the Issue:
Apex Test Execution tells me that the Test passes the test but I only have 50% code coverage because it wont take all the lines with the contactsToUpdate List. 
As you can see in:
User-added image

Many many thanks in advance!! I really hope someone can help me with that!

Best

Sam
I have a custom Object called Orders
My Project is to  update the Active Field (which is a picklist) has two values 'yes' and 'no'
Start date is less than today and end date is greater than today then Active field should be 'yes' otherwise 'no'.

I made this project with help of process builder and it worked fine,Let say that start date is something in the futuer for Ex:if today is 24th .I set the date as 26th in start date filed thn on 26th it should automatically become yes .

Please help me



 
Hi Experts,

I'm on a project that needs to maintain the account and contact information in such a way that, the contacts are assigned to designation in Account.
Additionally it is also required to maintain infomration on the designations.
For example, If an account's sales manager is being replaced by another contact, they still want to maintain the information stored on the Designation.

Initially I thought of creating a custom object. But I just want to check if there is any standard funcationity/object available.
If not what are the considerations/steps needs to be taken care on a custom object?

Regards,
Anto Nirmal
We have a VF page that displays one company logo in a certain condition, and another in all others.  Code is below:

<apex:image id="Logo" value="{!If(objLeadSite.Site__r.Company__r.Name=="XXXX", "https://c.na24.content.force.com/servlet/servlet.ImageServer?id=0151a000000nGvu&oid=00D1a000000XXXX","https://c.na24.content.force.com/servlet/servlet.ImageServer?id=0151a000000nGvy&oid=00D1a000000YYYY")}" />

Now, when I land on this page from a related record that should match the Company Name, instead I am presented the "else" image.

What am I missing?
Hello All!

I am using this formula to calculate the term in months from effective date to end date. Works great if the months are different. However, it appears to be adding a month if my effective and end dates are in the same month.

e.g. Effective Date: 11/23/2015
       End DAte: 11/22/2016
Calculating 13 month term.


Anyone know how I can resolve?

Data Type Formula    
Decimal Places 0    
IF(NOT(ISBLANK(Service_End_Date__c)) && NOT(ISBLANK(Service_Effective_Date__c)) 
,(((YEAR(Service_End_Date__c ) - YEAR(Service_Effective_Date__c ) - 1) *12) + (12 - MONTH(Service_Effective_Date__c) +1) + MONTH(Service_End_Date__c )) 
, null 
)
Hello

Here is the trigger that was created... pleass help!!

trigger UpdatePartnerOpportunity on Opportunity (before insert, before update) {
// THIS TRIGGER WILL OVERWRITE ANY PARTNER DEFINED IN THE FIELD Partner ON THE Opportunity OBJECT.
// SET THIS FIELD TO READ ONLY OR CHANGE THE FUNCTIONALITY BELOW TO AVOID DATA BEEING OVERWRITTEN BY MISTAKE...

   for (Opportunity o : Trigger.new) {

       // CREATE ARRAY OF ALL PARTNERS ON THIS OPPORTUNITY. THE REASON WHY WE DONT PICK THE PRIMARY PARTNER ONLY
       // IS BECAUSE THE PRIMARY FLAG IS NOT ALWAYS SET WHEN PARTNERS ARE ADDED TO OPPORTUNITIES. ONLY WHEN SALES DOES TIS
       // MANUALLY FROM THE RELATED LIST IS PRIMARY CHECKBOX CHECKED...

                       System.debug(' output inside ' + o);

       OpportunityPartner[] PartnerArray = 
       [select AccountToID, IsPrimary from OpportunityPartner where OpportunityId = :o.id ORDER BY isPrimary DESC, CreatedDate];
       
                              System.debug(' PartnerArray ' + PartnerArray);

       if (PartnerArray.size() > 0) {
         
           // IF PRIMARY IS DEFINED THEN THIS WILL BE THE FIRST OBJECT. IF NOT THE FIRST ADDED PARTNER WILL BE ADDED...
                     List<Opportunity> AccountArray = [select id,Partner_on_Opportunity__c from Opportunity where Id = :o.AccountId ];
           for (Opportunity a: AccountArray ){
                       o.Partner_on_Opportunity__c=PartnerArray[0].AccountToID;
                       System.debug(' output inside' + o.Partner_on_Opportunity__c);
            update o;
                       }
            
       }else{
      
           // IF NO PARTNERS EXIST RETURN NULL...
           o.Description = 'No Partner';
           System.debug(' Output else statement' + o.Description);
           
       }
   }
 }
Hello, 

I have a custom object named: JAT

I'm looking for two things:

1) when a user enters a date into the Due Date field, I would like a task to be created for the running user when a new JAT record is created
2) if the user enters a due date of 12/30/2015, I'd like an email sent to the running user of the reminder to be sent 1 week prior of the due date

Can someone help me in creating these? 
Which method is best to do these in: Process Builder or a Workflow?

Thank you!

User-added image
 
Hi Guys,
<apex:input type="date" value={!somevalue}/>

in the above situation how can i disable the future dates in that date puicker..please help me....thanks in advance..
I want to know the number of specified day say(Sun, Mon or Sat) within the specified date range example (11/01/2014 to12/16/2015). Is there any formula to calculate this, such as we pass these two dates as input and get the number of specified day between this date range?. Kindly suggest.
Hi there
I have a contact record called "King Koo" with email address king.koo@test.com.

I set up a Matching Rule on Contact - Matching Criteria is
(Contact: LastName
FUZZY: LAST NAME
MatchBlank = FALSE) 
AND 
(Contact: Email
EXACT
MatchBlank = FALSE)

And I set up Duplicate Rule to allow on create with Alert and Report, tying it to the Matching Rule above.

I then created a Lead with the same info as the Contact, and then on Convert, I get to a screen like the following.  

My confusion is that the "Convert to Existing Contact" gives me an empty list, when I was expecting to see the info of the matching Contact record.  With no records showing there, obviously the "Convert to Selected" doesn't make sense.

As far as I'm concerned, the duplicate management is not doing anything.

Am I missing some steps?

Thanks
King

User-added image
In our integration we bring over sales orders (Master Relationship) and sales order lines (Child) both are different objects, we also bring credits and returns into the same objects. 
When we right a credit or return we bring over the original sales order number and it lands on the child record (line).  What I need is to convert that original sales order number into an ID so that I can link the credit or return to the original sales order.  I need the ID to land in a lookup field using some type of apex code.
Any help is appreciated, new to apex coding.
 
Hi All,

I have a batch class that sends an email in the finish() method whenver errors are present. The email distribution list is set up under custom settings so it can be easily adjusted without having to directly modify the code in a sandbox, turn off the batch schedule, push the new code in, and turn the schedule back on.

I'm being a bit anal about this, but I would like to see 100% code coverage for my batch class - but I'm not sure how to write it up in my test class approrpriately. 

Here's the finish method:
global void finish(Database.BatchableContext BC) {
		AsyncApexJob job = [SELECT Id, ApexClassId, JobItemsProcessed, TotalJobItems, NumberOfErrors, CreatedBy.Email
							FROM AsyncApexJob WHERE Id = :BC.getJobId()];

		if(failedUpdates > 0 || job.NumberOfErrors > 0) {
			String emailMessage = 'Batch Job TaskUpdateActivityInfo has errors. <br/><br/>'
								 +'Number of batches: ' + job.TotalJobItems + '<br/>'
								 +'Number of successful batches: ' + job.JobItemsProcessed + '<br/>'
								 +'Number of unsuccessful batches: ' + job.NumberOfErrors + '<br/>'
								 +'Number of unsucessful record updates: ' + failedUpdates + '<br/><br/>'
								 +'For more details, please review the Apex Errors tab.';

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

			//Uses custom setting to add other email addresses
			String[] toAddresses = new String[] {job.CreatedBy.email};

			Map<String, Apex_Distribution_List__c> distList = Apex_Distribution_List__c.getAll();
	        String serverhost = URL.getSalesforceBaseUrl().getHost().left(2);

	        for(Apex_Distribution_List__c record : distList.values()) {
	            //If it's a produciton environment, add only system admin emails
	            if(serverHost == 'na')
	            	if(record.System_Admin_Email__c)
	            		toAddresses.add(record.Email__c);
	            //Otherwise, only add those that are enabled for sandbox alerts
	            else
	                if(record.Enabled_for_Sandbox_Alerts__c)
	                	toAddresses.add(record.Email__c);
	        }

			mail.setToAddresses(toAddresses);
			mail.setReplyTo('kkorynta@navicure.com');
			mail.setSenderDisplayName('Salesforce Apex Batch Job Summary');
			mail.setSubject('Salesforce Batch Job Summary: Task Update Activity Info');
			mail.setHTMLBody(emailMessage);
			Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
		}
	}

These are the lines I'm not able to get coverage on:
//If it's a produciton environment, add only system admin emails
	            if(serverHost == 'na')
	            	if(record.System_Admin_Email__c)
	            		toAddresses.add(record.Email__c);
	            //Otherwise, only add those that are enabled for sandbox alerts
	            else
	                if(record.Enabled_for_Sandbox_Alerts__c)
	                	toAddresses.add(record.Email__c);


Does anyone have any suggestions on how to get coverage on this? I'm at 91% currently.

Thanks,
Kelly
Hi All,

I am new to salesforce and learning on it. I have a difficulty while using a workflow/process builder. 

I have two custom objects, say Result (parent) and Score (Child), with a master detailed relationship.

I want to write a workflow such that it uses both child object field and parent object field as criteria for process builder.

Ex. If Result is >=80, and Score.name = Maths and Score.marks >=90 , then a email alert should fire.

I tried to write the workflow on Score object (child), but since I am using the parent object field (result) in the criteria, workflow is not triggering. 

Could you please help me on this case.

Thanks in advance.

Regards,
I would like some help with a fairly simple request: I have a process builder setup to run on opportunities. It works fine but only when the record is updated. I would like to have it run every day and execute if a field date on the record is matched to today's date. I don't want to set it to run in the future. Just an everyday event.
I tried forcing the execution with workflow rules updating a date field on the record but it doesn't work when the date is tomorrow or the following date. Nothing happens when the future date comes around.
Is there another trick I'm missing and I can't see a way to trigger this process builder?
Thanks in advance for your help!
I'm really stuck here...

Tried creating the workflow for Trailhead Module 2 "Create a flow to streamline entry of new accounts, contacts and opportunities".  Saved and made active, tried to test and got an unhelpful error message.  Now I cannot reopen the message to edit, and since its active I can't delete to start over either.  Error message on open is:
User-added image
Thanks in advance for any help...
Hi all,

I have a requirement, whenever user login into salesforce it should display one popup with lead status. I made my visualforce page as default landing page(setup --> create --> apps -->edit)
Default Landing Tab --> (LeadHome)My Visualforce page.
But it is not displaying my VF page whenever I login into salesforce. Any one please help me.
 
Hi Experts,

in our global actions we are using visualforce page.
But in global action it is showing Visulaforce Id not Name.

Please find below image.

User-added image

Someone help me out
Hi,

I'm looking to edit the logic on my views so that the logged in user can only see the records that they themselves have created for ordering purposes on a custom object. 

So far what I have is:


IF(
CreatedbyID = $User.id  )

However not really sure where to go from from here. Any assistances would be appreciated.
 
I am curious, I know that Salesforce works for Outlook but will it work for the web version? We have some employees who work remotely in different countries so they access the company outlook from the outlook website, not the computer program. 

Any and all help is appreciated, I am not great at this stuff but yet it's my responsibility so help me look good :) 

I am using Open ID connect as the Authentication provider , and I am using my gmail user id fro logging in from my IP to Salesforce communities, which is the service provider via this open id connect sso implementation. So now when I am logging out from the gmail account , I am still looged in to the Salesforce community session, what I am expecting is that the user will also be logged out from the same Salesforce communities session also.Your help will be much appreciated.
hii friends how can write soql query for this one pls suggest me..to retrieve the opportunities that are closed on friday in the years 2013and 2015hii friends how can write soql query for this one pls suggest me..
Hallo, 

since I am new to Apex and specially this forum please dont be so hard on me. 

I am trying to get this to work: 

(Short explenation of the porpuse: When sending out a Mail with a specific Subject, the contact field "Recruiting_Status__c" should be updated on the contact related to the task (WhoId). 

Note: I tried to do include the contact to my list and update on two different ways as you may notice (last one is different), but code coverage keeps telling me somethings wrong.. 

Trigger: 
trigger RecEmailTrigger on Task (after insert) {
    List<Contact> contactsToUpdate = new List<Contact>();
    
    for(Task t : Trigger.new) {
        if (t.WhoId != null){
        
        List<Contact> Con = [SELECT Id, Name, Recruiting_Status__c 
                             FROM Contact 
                             WHERE Id = :t.WhoID];
        
        if(t.subject.equals('Email: Anfrage auf vollständige Bewerbungsunterlagen')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Requested complete set of documents'));}     
        
        else if(t.subject.equals('Email: Das AUCTUS Recruiting Erlebnis: selbständige Terminkoordination für ein erstes Vorabgespräch')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'In scheduling process for initial conversation'));}
        
        else if(t.subject.equals('Email: Das AUCTUS Recruiting Erlebnis: selbständige Terminkoordination für die CaseStudy@Home')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'In scheduling process for case study'));} 
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && (Con[0].Recruiting_Status__c.contains('preselected') || Con[0].Recruiting_Status__c.contains('Requested complete') )) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after preselection'));}  
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('initial conversation')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after initial conversation'));}  
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('case study')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after case study'));}
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('IM-interview')) {
        contactsToUpdate.add(new Contact(Id = t.WhoId, Recruiting_Status__c = 'Declined after IM-interview'));}
        
        else if((t.subject.equals('Email: Vielen Dank für Ihre Bewerbung') || t.subject.equals('Email: Vielen Dank für Ihre Kontaktaufnahme'))
        && Con[0].Recruiting_Status__c.contains('partner/MD interview')) {
        Con[0].Recruiting_Status__c = 'Declined after partner interview';
        contactsToUpdate.addAll(Con);}
        
    } 
    }
     update contactsToUpdate;
}
Test Class:
@IsTest
public class TestRecEmailTrigger {

        static testmethod void insertTask() {
        
        User us = new User();
        
        us.FirstName = 'Test';
        us.LastName = 'User';
        us.Alias = 'UserTest';
        us.Email = 'samuel.schoessel@gmx.de';
        us.Username = 'samuel.schoessel@gmx.de';
        us.CommunityNickname = 'Sammy';
        us.TimeZoneSidKey = 'Europe/Berlin';
        us.LocaleSidKey = 'de_DE';
        us.EmailEncodingKey = 'UTF-8';
        us.LanguageLocaleKey = 'en_US';
        us.ProfileId = '00e24000000Mca5';
        
        insert us; 
         
        Account acc = new Account(); 
        
        acc.Name = 'Test Account';
        acc.RecordTypeId = '012240000004qdf';
        acc.OwnerId = us.Id;
        
        insert acc;
        
        Contact con = new Contact();
        
        con.LastName = 'The Sam';
        con.FirstName = 'Sammy';
        con.OwnerId = us.Id;
        con.RecordTypeId = '012240000006HOl'; 
        con.Recruiting_Status__C = 'Scheduled for initial conversation';  
        
        insert con;  
         
        Task t = New Task();
        
        t.Subject = 'vollständige Bewerbungsunterlagen';
        t.Priority = 'Normal';
        t.Status = 'Geschlossen';
        t.OwnerId = us.Id;
        t.WhoId = con.Id;
                
        insert t;
        }
    }

Back to the Issue:
Apex Test Execution tells me that the Test passes the test but I only have 50% code coverage because it wont take all the lines with the contactsToUpdate List. 
As you can see in:
User-added image

Many many thanks in advance!! I really hope someone can help me with that!

Best

Sam
I have a custom Object called Orders
My Project is to  update the Active Field (which is a picklist) has two values 'yes' and 'no'
Start date is less than today and end date is greater than today then Active field should be 'yes' otherwise 'no'.

I made this project with help of process builder and it worked fine,Let say that start date is something in the futuer for Ex:if today is 24th .I set the date as 26th in start date filed thn on 26th it should automatically become yes .

Please help me



 

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.