• vinni1
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hi All,

 

Please help me on bellow error

 

Error: Compile Error: Initial term of field expression must be a concrete SObject: List<New__c> at line 17 column 33

 

R_Type__c is picklist filed

 

trigger Updateallcases on Case (after insert) {
 
  List<Case> updatedCases=new List<Case>();
  List<RecordType> recType = [select id from RecordType where name = 'New Rec' AND sobjecttype = 'Case' AND IsActive = TRUE limit 1];
  List<New__c> customSettingMap = New__c.getall().values();
 
  if(!recType.isempty())
  {
   String RecordTypeAid = rectype[0].id;
   for(case c : Trigger.new)
   {
     if(c.RecordTypeId == RecordTypeAid )
     {
          if(c.Comments__c == customSettingMap.External__c)
          {
            c.R_Type__c = customSettingMap.Case_Type__c;
            updatedCases.add(c);
          }
        
     }
 
   }
  }
  Update updatedCases;
}

  • October 22, 2013
  • Like
  • 0

Hi All,

 

  Req: if we update task field  under lead , Lead date field get update

 

   Trig::  It works perfectly

 

      trigger TaskAfterInsertUpdate on Task (after update, after insert){
    list<Lead> leads = new list<Lead>();
    list<id> alliIDs = new list<id>();
    datetime myDateTime = datetime.now();
    
    Id taskRecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Old One').getRecordTypeId();

    for(Task sTask : trigger.new)
    {
        if (sTask.WhoId <> NULL && sTask.RecordTypeid == taskRecordTypeId && string.valueOf(sTask.WhoId).startsWith('00Q'))
        {
            alliIDs.add(sTask.Whoid);
        }
    }

    Map<Id,Lead> leadmap = new Map<Id, Lead>([select Id,BU__c,Last_Date__c,CreatedDate,LeadSource,Country,Status,DonotCall,Mobile__c ,Phone__c from Lead where Id in : alliIDs]);
    Map<Id,Lead> allMap = new Map<Id, Lead>();

    for(Lead lead : leadmap.Values()){
        idcreateddateMap.put(lead.Id,lead);
    }

    for(Task tsk :Trigger.new){
        if (tsk.WhoId <> NULL && tsk.RecordTypeid == taskRecordTypeId && string.valueOf(tsk.WhoId).startsWith('00Q')){
            
                    if(allMap .get(tsk.WhoId).CreatedDate.Date().daysBetween(myDateTime.Date())>10& allMap .get(tsk.WhoId).Status <> 'Open' && allMap .get(tsk.WhoId).LeadSource == 'All Data' &&(tsk.Outcome__c == 'Back Me' || tsk.Outcome__c=='ywefuw' || tsk.Outcome__c=='My all' || tsk.Outcome__c == 'Get one') && tsk.Type == 'Out'){
                        idcreateddateMap.get(tsk.WhoId).Last_Date__c = NULL;   

                    }
                    
                    leads.add(idcreateddateMap.get(t.WhoId));

              
        }
    }
    update leads;
}

 

 

Test Class::  but it's not cover fully

 

@isTest
public class TestTaskAfterInsertUpdate
{
  static testMethod void TestTaskAfterInsertUpdate()
  {
     task t = new task(Subject='Call',Type='Outbound Call',Status='Not Started',Priority='Normal');
     insert t;
  }
  }
 

 

Hi All,

 

  Please help me for writing test class

 

Trigger::

 

trigger UpdateLead on Lead(before update) {
    List<Lead> allleads = new List<Lead> ();
    Set<Id> leadIds = new Set<Id> ();
    datetime myDateTime = datetime.now();
    if(Trigger.isUpdate){
        for (Lead newlead: Trigger.new) {
            Lead oldLead = Trigger.oldMap.get(newlead.Id);     
             if ((newlead.Mobile__c == 'M' || newlead.Phone__c == 'N')  && (newlead.Last_Successful_c == NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())>7)){
                newlead.DonotCall= true;
               newlead.Status = 'Closed';
                newlead.Closed_Reason__c = 'all';
            }
             else if ((newlead.Mobile__c == 'M' || newlead.Phone__c == 'Y')  && (newlead.Last_Successful_c == NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())>7)){
                newlead.DonotCall= true;
                newlead.Status = 'Closed';
                newlead.Closed_Reason__c = 'all';
            }
                                          
              if ((newlead.Mobile__c  == 'M' || newlead.Phone__c == 'N')  && (newlead.Last_Successful_c <> NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())<=7)){
                newlead.DonotCall= true; 
                newlead.Status = 'Closed';  
                newlead.Closed_Reason__c = 'all';          
            }                          
              else if ((newlead.Mobile__c  == 'M' || newlead.Phone__c == 'Y')  && (newlead.Last_Successful_c <> NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())<=7)){
              newlead.DonotCall= false;             
            }

        }
    }
}

 

Test Class:

 

@isTest
public class TestUpdateLead
{
  static testMethod void myTest()
  {
   
    Lead l = new lead(LastName='Test123',Company = 'Hp',Email='hp@hp.com',Phone='9738335102',Mobile__c = 'M',Phone__c = 'N',Last_Successful__c = NULL,CreatedDate= System.now()-7);
   
    insert l;
   
   
  }
}

Hi All,

 

 Need  for Trigger

 

Trigger ::

 

trigger UpdateLead on Lead(before update) {
    List<Lead> allleads = new List<Lead> ();
    Set<Id> leadIds = new Set<Id> ();
    datetime myDateTime = datetime.now();
    if(Trigger.isUpdate){
        for (Lead newlead: Trigger.new) {
            Lead oldLead = Trigger.oldMap.get(newlead.Id);     
             if ((newlead.Mobile__c == 'N' || newlead.Phone__c == 'N')  && (newlead.Last_Successful_c == NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())>7)){
                newlead.DonotCall= true;
               newlead.Status = 'Closed';
                newlead.Closed_Reason__c = 'all';
            }
             else if ((newlead.Mobile__c == 'N' || newlead.Phone__c == 'Y')  && (newlead.Last_Successful_c == NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())>7)){
                newlead.DonotCall= true;
                newlead.Status = 'Closed';
                newlead.Closed_Reason__c = 'all';
            }
                                          
              if ((newlead.Mobile__c  == 'N' || newlead.Phone__c == 'N')  && (newlead.Last_Successful_c <> NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())<=7)){
                newlead.DonotCall= true; 
                newlead.Status = 'Closed';  
                newlead.Closed_Reason__c = 'all';          
            }                          
              else if ((newlead.Mobile__c  == 'N' || newlead.Phone__c == 'Y')  && (newlead.Last_Successful_c <> NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())<=7)){
              newlead.DonotCall= false;             
            }

        }
    }
}

 

Test Class::

 

@isTest
public class TestUpdateLead
{
  static testMethod void myTest()
  {
   
    Lead l = new lead(LastName='Test123',Company = 'Hp',Email='hp@hp.com',Phone='9738335102',C_Mobile_Opt_in1__c = 'N',Phone_Opt_in__c = 'N',Last_Successful_Call__c = NULL,CreatedDate= System.now()-7);
   
    insert l;
   
    list<lead> l1 = [select id,lastname,phone from lead where lastname='Test123' limit 1];
    system.AssertEquals('Test123',l1[0].lastname);
      }
}

Hi All,

 

I have 3 objects account,contact and DummyContact . account and cotact have Master detail relation ship..

 My Req is capure the deleted contact records under Account  in to DumayContact object

 

 

please help for this

 

trigger DuplicateContact on Contact (after delete)
{
set<id> allacc = new set<id>();
for(contact allcon:trigger.old)
{
allacc.add(allcon.id);
system.debug('old====>'+allacc);
}
list<contact> allconss = [select id,name,accountid from contact where accountid=:allacc];

  • April 17, 2013
  • Like
  • 0

Hi,

Please help me for querying opportunity....

 

How to query the opportunity field history records in Developer console...

  • April 01, 2013
  • Like
  • 0

Hi All,

 

Please help me on bellow error

 

Error: Compile Error: Initial term of field expression must be a concrete SObject: List<New__c> at line 17 column 33

 

R_Type__c is picklist filed

 

trigger Updateallcases on Case (after insert) {
 
  List<Case> updatedCases=new List<Case>();
  List<RecordType> recType = [select id from RecordType where name = 'New Rec' AND sobjecttype = 'Case' AND IsActive = TRUE limit 1];
  List<New__c> customSettingMap = New__c.getall().values();
 
  if(!recType.isempty())
  {
   String RecordTypeAid = rectype[0].id;
   for(case c : Trigger.new)
   {
     if(c.RecordTypeId == RecordTypeAid )
     {
          if(c.Comments__c == customSettingMap.External__c)
          {
            c.R_Type__c = customSettingMap.Case_Type__c;
            updatedCases.add(c);
          }
        
     }
 
   }
  }
  Update updatedCases;
}

  • October 22, 2013
  • Like
  • 0

Hi All,

 

 Need  for Trigger

 

Trigger ::

 

trigger UpdateLead on Lead(before update) {
    List<Lead> allleads = new List<Lead> ();
    Set<Id> leadIds = new Set<Id> ();
    datetime myDateTime = datetime.now();
    if(Trigger.isUpdate){
        for (Lead newlead: Trigger.new) {
            Lead oldLead = Trigger.oldMap.get(newlead.Id);     
             if ((newlead.Mobile__c == 'N' || newlead.Phone__c == 'N')  && (newlead.Last_Successful_c == NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())>7)){
                newlead.DonotCall= true;
               newlead.Status = 'Closed';
                newlead.Closed_Reason__c = 'all';
            }
             else if ((newlead.Mobile__c == 'N' || newlead.Phone__c == 'Y')  && (newlead.Last_Successful_c == NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())>7)){
                newlead.DonotCall= true;
                newlead.Status = 'Closed';
                newlead.Closed_Reason__c = 'all';
            }
                                          
              if ((newlead.Mobile__c  == 'N' || newlead.Phone__c == 'N')  && (newlead.Last_Successful_c <> NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())<=7)){
                newlead.DonotCall= true; 
                newlead.Status = 'Closed';  
                newlead.Closed_Reason__c = 'all';          
            }                          
              else if ((newlead.Mobile__c  == 'N' || newlead.Phone__c == 'Y')  && (newlead.Last_Successful_c <> NULL && newlead.CreatedDate.Date().daysBetween(myDateTime.Date())<=7)){
              newlead.DonotCall= false;             
            }

        }
    }
}

 

Test Class::

 

@isTest
public class TestUpdateLead
{
  static testMethod void myTest()
  {
   
    Lead l = new lead(LastName='Test123',Company = 'Hp',Email='hp@hp.com',Phone='9738335102',C_Mobile_Opt_in1__c = 'N',Phone_Opt_in__c = 'N',Last_Successful_Call__c = NULL,CreatedDate= System.now()-7);
   
    insert l;
   
    list<lead> l1 = [select id,lastname,phone from lead where lastname='Test123' limit 1];
    system.AssertEquals('Test123',l1[0].lastname);
      }
}