• ronyc
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies

Hello frnds,

 

 

I have a requirement where, whenever a user logins into the salesforce.com UI a welcome email should be sent to them.

I tried to create work flow rule where criteria is

 

"Last Login equals Today "

and then added a work flow action Email Alert,  where it will send an email from users current email address to user itself email template is also added in it.

 

Any one has come across this type of requirement? if yes please let me know how can we acheive it and if not any solutions.

 

Thanks in advance,

Rony

  • November 12, 2013
  • Like
  • 0

Hi team,

 

I have written 1 trigger which will send an email to the Account owner and the contact whenever a Visit(custom objct child of accnt) record is created.

 

This is the test class i have written and the code coverage shows 29 %. i am not sure how to include email services in the Test class . can you please help me out.

 

below is the trigger and test class I have written.

 

trigger Send_Email_Visit on Visit__c (after insert,after update) {
Set<Id> Poc1IdSet = new Set<Id>();
Set<Id> Loctn = new Set<ID>();
for(Visit__c Visit :Trigger.new){
Poc1IdSet.add(Visit.POC_1__c);
Loctn.add(Visit.Location__c);
List<String> List1 = new List<String>();
for(Account acc :[Select owner.Email from Account where Id in :Loctn]){
List1.add(acc.Owner.Email);
}   
Messaging.SingleEmailMessage MessageEmail = new Messaging.SingleEmailMessage();
if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='Walmart'){
MessageEmail.setTemplateId('00Xd00000019U0mEAE');
MessageEmail.setTargetObjectId(Visit.POC_1__c);
MessageEmail.setWhatId(Visit.ID);
MessageEmail.setToAddresses (List1);
MessageEmail.setSaveAsActivity(False); 
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {MessageEmail}); 
}else if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='AE'){
MessageEmail.setTemplateId('00Xd00000019paUEAQ');
MessageEmail.setTargetObjectId(Visit.POC_1__c);
MessageEmail.setWhatId(Visit.ID);
MessageEmail.setToAddresses (List1);
MessageEmail.setSaveAsActivity(False); 
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {MessageEmail});
 } else if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='TRU'){
MessageEmail.setTemplateId('00Xd00000019qvBEAQ');
MessageEmail.setTargetObjectId(Visit.POC_1__c);
MessageEmail.setWhatId(Visit.ID);
MessageEmail.setToAddresses (List1);
MessageEmail.setSaveAsActivity(False);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {MessageEmail}); }
else if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='GAPINC'){
MessageEmail.setTemplateId('00XJ0000000NNcVMAW');
MessageEmail.setTargetObjectId(Visit.POC_1__c);
MessageEmail.setWhatId(Visit.ID);
MessageEmail.setToAddresses (List1);
MessageEmail.setSaveAsActivity(False); 
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {MessageEmail}); } 
else if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='Belk'){
MessageEmail.setTemplateId('00Xd00000019U0lEAE');
MessageEmail.setTargetObjectId(Visit.POC_1__c);
MessageEmail.setWhatId(Visit.ID);
MessageEmail.setToAddresses (List1);
MessageEmail.setSaveAsActivity(False); 
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {MessageEmail}); }
else {
}
}
}

 

Test class:

 

@istest
private class sendemailvisit 
{
static testmethod void insertvisitrecord()
{
Visit__c visit=new Visit__c();
visit.Location__c='001d000000HiIqd';
visit.Visit_Performed_By__c='005d0000001C6IE';
visit.Visit_Channel__c='Phone';
visit.Visit_Goal__c='Grow Applications';
visit.Primary_Visit_Focus__c='Recognition';
visit.Location_Manager_Level_of_Receptiveness__c='High';
visit.Recognition_ranking__c='High';
visit.Expectations_ranking__c='High';
visit.Accountability_ranking__c='High';
visit.Coaching_ranking__c='High';
visit.Collater_ranking__c='High';
visit.Communications_ranking__c='High';
visit.Training_ranking__c='High';
visit.X9_Was_this_a_planned_visiti__c='Scheduled';
visit.Send_Email__c=True;

insert visit;

if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='Walmart'){

System.assertEquals(visit.Send_Email__c,True); 
}

}

 

please have a look into it and let me know how can I increase the test coverage.

 

Any Help on this will be highly appreciated.

  • July 12, 2013
  • Like
  • 0

Hi team,

 

I am writing a trigger to update a field in Account object(PVF_value__c) . Account is having a Detail called Visit__c which has 2 fields Location__c (Acount) and Primary_visit_focus__c .

 

So whenever a visit is created on a account it should update the field in Account.

Below is the code and the error i am getting.

 

trigger Acct_pvf_value on Account (after insert,after update) {
 for(Account acc :Trigger.new()){
List<String> IDpvf = new List<String>();
IDpvf.add(acc.ID);
Map<ID,Visit__c> VisMap =  new Map<ID,Visit__c>([Select Location__c,Primary_Visit_Focus__c from Visit__c where Location__c in :IDpvf ]);
for(Visit__c visit : VisMap.keyset())
{
if(acc.id == VisMap.get(visit).Location__c){
acc.PVF_value__c= VisMap.get(visit).Primary_Visit_Focus__c;
}
update IDpvf;
}
}
}

Error: Compile Error: Incompatible key type SOBJECT:Visit__c for MAP<Id,Visit__c> at line 9 column 19

Any help on this is highly appreciated

  • June 07, 2013
  • Like
  • 0

Hi Team,

 

I recently installed the Force.com IDE plug in in Eclipse 3.6(indigo).

When i am trying to create a new project and clik on next it displays an error saying " Unable to fetch organization details for (my usename)".

 

Can anyone please help me in getting this corrected?

 

Thanks,

Rony

  • May 24, 2013
  • Like
  • 1

Hi Team,

 

I recently installed the Force.com IDE plug in in Eclipse 3.6(indigo).

When i am trying to create a new project and clik on next it displays an error saying " Unable to fetch organization details for (my usename)".

 

Can anyone please help me in getting this corrected?

 

Thanks,

Rony

  • May 24, 2013
  • Like
  • 1

I am not sure how to write this formula field (I am very new to this).  I have a field on the Acccount that is called National_Account_Status__c, this is a picklist with the following options:  None, Targeted, Current.  I need to just make an easy formula field to copy this field and the value over to the Opportunity.  What I did was create a field forumal named it and put int the formula Account.National_Account_Status__c, seems easy.  However I get the error that it is a picklist and I need to us ispickval.  I have used this in a formula field before but it was to calculate something.  I am not sure how to use it here.  

 

Again all I need is to copy this field over to the Opp.  One question though, if I create a new field with this formula field, will this work on Opporutnities that are already created or just new Opps? 

 

Thank you very much!

Hi team,

 

I am writing a trigger to update a field in Account object(PVF_value__c) . Account is having a Detail called Visit__c which has 2 fields Location__c (Acount) and Primary_visit_focus__c .

 

So whenever a visit is created on a account it should update the field in Account.

Below is the code and the error i am getting.

 

trigger Acct_pvf_value on Account (after insert,after update) {
 for(Account acc :Trigger.new()){
List<String> IDpvf = new List<String>();
IDpvf.add(acc.ID);
Map<ID,Visit__c> VisMap =  new Map<ID,Visit__c>([Select Location__c,Primary_Visit_Focus__c from Visit__c where Location__c in :IDpvf ]);
for(Visit__c visit : VisMap.keyset())
{
if(acc.id == VisMap.get(visit).Location__c){
acc.PVF_value__c= VisMap.get(visit).Primary_Visit_Focus__c;
}
update IDpvf;
}
}
}

Error: Compile Error: Incompatible key type SOBJECT:Visit__c for MAP<Id,Visit__c> at line 9 column 19

Any help on this is highly appreciated

  • June 07, 2013
  • Like
  • 0

Hi team,

 

I am wrting a Trigger to send an email whenever a Visit__c (custom object) record is created. Visit__c has a custom field named Poc_1_c which is nothing but a look up to contact.

So now when I create a Visit record the email should go to the POC.

Below is the Trigger I wrote and the error I am getting

 

trigger Send_Email_Visit on Visit__c (after insert,after update) {

Set<Id> Poc1IdSet = new Set<Id>();
  for(Visit__c Visit :Trigger.new){
  Poc1IdSet.add(Visit.POC_1__c);
  List<String> List1 = new List<String> ([Select Email from Contact where id in :Poc1IdSet]);
     
  Messaging.SingleEmailMessage MessageEmail = new Messaging.SingleEmailMessage();
 
   String toaddress = new String[] {List1.Email};
  
  
   if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='Walmart')
        {
        MessageEmail.setTemplateId('00XK0000000QN37');
        MessageEmail.setTargetObjectId(Visit.CreatedByID);
        MessageEmail.setToAddresses (toaddress);
        MessageEmail.setSaveAsActivity(False);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {MessageEmail});
        }
        }
   
   }

Error: Compile Error: Invalid initial value type LIST<Contact> for LIST<String> at line 6 column 24

 

Can ANyone please help me on this?

 

Thanks in advance