• Tejas Wadke 5
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 4
    Replies
Code
+++++++++++++++++++
trigger ICADCPASort on icad__CPA__c (after insert) 
{
     List<CPA__c> CPAIds = new List<CPA__c>();
     List<Test__c  > TestIds = new List<Test__c>();  
for(CPA__c np: Trigger.new)
    {
     CPAIds.add(np);
    }
for(CPA__c np: CPAIds)
    {
    
        Test__c st = new Test__c();
        Id devRecordTypeId = Schema.SObjectType.Test__c.getRecordTypeInfosByName().get('CPA').getRecordTypeId();   
        st.CPA__C = np.Id;
        st.Test_Name__c = 'CPA';
        st.icad__Student_Name__c = np.icad__Name_of_the_Candidate__c;
        st.icad__Email__c = np.icad__Student_Email_id__c;
        TestIds.add(st); 
        }
 insert TestIds;
     
       Student_Details__c sd =new Student_Details__c();       
        sd.CPA__c = np.Id; 
        sd.Student_Name__c = np.Name_of_the_Candidate__c;
        sd.Birth_Date__c = np.Birth_Date__c;
        sd.Cast_Category__c = np.Cast_Category__c;
        sd.Name_of_School__c = np.Name_Of_School__c;
        sd.Residential_Add__c = np.Residential_Add_del__c;
        sd.Dist__c = np.City__c;
        sd.Pin__c = np.Pin__c;
        sd.Landline__c = np.Home_Phone_No__c;
        sd.Parents_Mob__c = np.Parents_Mob__c;
        sd.Students_Mob__c = np.Student_Phone_No__c;
        sd.Parent_s_Email__c = np.Parent_Email_id__c;
        sd.Student_s_Email__c = np.Student_Email_id__c;
        sd.Candidate_s_Photo__c = np.Candidate_s_Photo__c;
        sd.icad__Test__c=st.id;
  insert sd; 
   }

 
Hello,

---------TRIGGER----------

trigger UpdateReportName on ActivityPlanningAndReport__c (before insert) {
     Map<Id,User> ownerMap;
     Set<Id> oppOwnerIds = new Set<Id>();
     String nameOfOwner;
     for(ActivityPlanningAndReport__c p : trigger.new)
    {
        oppOwnerIds.add(p.OwnerId);
    }
     ownerMap = new Map<Id,User>([SELECT Id, Name FROM User WHERE Id IN :oppOwnerIds]);
     for(ActivityPlanningAndReport__c p : trigger.new)
     {
          nameOfOwner = ownerMap.get(p.OwnerId).Name;
        if(p.Name!=null)
        {
            p.Name = p.Country_txt__c+'_'+ p.Display_Engagement_Date__c+'_'+nameOfOwner;
     }
     }   
   }
Hello,

I have a number field in Contact Object(Parent).
I want to create multiple records in Case Object(child)  based on the value in  number field in Contact Object.

Thanks,
Tejas
Hello,

I want to implement a functionality
Where on a button click Phone number field will eliminate non-numeric values
There are phone numbers like 030 / 3906 345-61 ,07272 / 7704 1245 O etc,I want to eliminate all non-numeric values in these numbers.
Any sample code snippet on this.

Thanks,
Tejas
Hello,

I am getting this error while I login to salesforce CRM connect offline

ERROR : -
Entity is not currently part of your offline datastore. Select create able, custom, delete able, key prefix, name, nameEx, query able, update able, userID, from Entity where userid=” XXXX000000XXXXXXXX”

Thanks,
Tejas

 
Hello,

Below is my URL 
http://surveybuilder-developer-edition.na30.force.com/DynamicComponent?id={!Contact.Feedback_ID__c}&fullname={!URLENCODE(Contact.FirstName)}{!URLENCODE(Contact.LastName)}&email={!URLENCODE(Contact.Email)}&phone={!URLENCODE(Contact.Phone)} 

I want to get the URL parameters fullname,email and phone in visualforce page.
Help on this please.

Thanks,
Tejas
 
Hello ,

I want to send an URL through an standard email template.
And i want the parameters to be encoded 

How's this possible any solution over it.

Thanks
Hi ,

I created a edit page using visualforce using custom controller but lookup fields are not visible.
How can i get over this.

Thank You.
Hi,

I want to insert duplicates contacts for associated accounts.
How is this possible using import tools.
I tried using jitterbit but it gives an error 'Creation of duplicate records'.
Please help me on this.
Thank you
Hello,

I have two lookup fields Company name(Account) and Contact Person(Contacts) on Visits object.Based on Company Name selected i want to filter the Contact person.

Thanks.
Hello,

This is my apex email body in the code.

   String body = 'Dear ' + con.firstname + ' ' + con.lastname + ',   ';
body += 'Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below.' ;
body +=  'Here’s the link  https://appfeedback-developer-edition.na30.force.com/survey/?email='+con.email+'&fullname='+con.firstname+ +con.lastname
 body += 'Best Regards,' ;

I want each of these lines on the new line.Currently it is displaying  in email as.

Dear Tejas Wadke, Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below. Here’s the link https://appfeedback-developer-edition.na30.force.com/survey/?email=tejas.wadke@aress.com&fullname=TejasWadkeBest Regards,https://www.tester.com?fullname=con.firstname+con.lastname

 
Hello,

I want to add a space between firstname and lastname.
I tried using %20 in an apex trigger but it does not accept the '%' and gives an error 'no viable character'.

https://appfeedback-developer-edition.na30.force.com/survey/?email='+con.email+'&fullname='+con.firstname+%20+con.lastname
Please help me on this.
Hello,
How can we integrate salesforce for outlook on mobile devices ?
I have two objects Contacts and Product.
Every contact has a product associated with it and every product has a product status i.e(Awarenes,Credibility,Connection,Advocating).
I want to display the values in one column mapping the contacts(KOL Name) with each product status.
The cell color will also vary according to the status. How can i implement this.
Please help me on this .

Order    KOL - Title/ Role   KOLName         Credibility  Awareness  Connection   Advocating
1.00      MNCP Manager    Keziah Malm      P-023      P-023           P-004          P-006

APEX PAGE
--------------------------------------------------------------------------
<apex:page standardController="Product_EntryStatus__c" extensions="tt" > <apex:pageBlock > <apex:pageBlockSection > <apex:pageBlockTable value="{!wrapper}" var="wrap"> <apex:facet name="Header">Advocating</apex:facet> <apex:column headerValue="Order" value="{!wrap.ordRec.Order__c}"/> <apex:column headerValue="KOL Title" value="{!wrap.kolRec.KOL_Title__c}"/> <apex:column headerValue="KOL Name" value="{!wrap.conRec.Key_Opinion_Leader__r.Name}"/> //<apex:column headerValue="Credibility" value="{!wrap.credRec.Name}"/> <apex:column headerValue="Awareness" value="{!wrap.accRec.Name}"/> <apex:column headerValue="Connection" value="{!wrap.connRec.Name}"/> <apex:column headerValue="Advocating" value="{!wrap.advoRec.Name}"/> <!-- you can add related fields here --> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:page>

APEX CLASS
------------------------------------------------------------------------
public class tt
{

   


   

 public Product_EntryStatus__c prod; 
    public List<Product_EntryStatus__c> accLst {get; set;}
    public List<Product_EntryStatus__c> conLst {get; set;}
    public List<Product_EntryStatus__c> kolLst {get; set;}
     public List<Product_EntryStatus__c> ordLst {get; set;}
     public List<Product_EntryStatus__c> credlst{get;set;}
     public List<Product_EntryStatus__c> connlst{get;set;}
       public List<Product_EntryStatus__c> convlst{get;set;}
        public List<Product_EntryStatus__c> advolst{get;set;}
   
   
    public List<MyWrapper> wrapper {get; set;}
    
    public List<Product_EntryStatus__c> getAdvocating()
{
    List<Product_EntryStatus__c> Advocating = [SELECT Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Advocating' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c,Key_Opinion_Leader__r.Name DESC NULLS LAST];
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:Advocating) {  
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
    Advocating= [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Advocating' and Country__c =: prod.Country__c and Product__c=: prod.Product__c  ORDER BY Order__c,Key_Opinion_Leader__r.Name DESC NULLS LAST];
    
    return Advocating;
    
}
    
    public List<Product_EntryStatus__c> getCredibility()
    {
    List<Product_EntryStatus__c>credlst= [SELECT id,Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Credibility' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c  ASC NULLS LAST];
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:credlst) {
 
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
     credlst = [SELECT id,Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Credibility' and Country__c =: prod.Country__c and Product__c=: prod.Product__c  ORDER BY Order__c ASC];
    
    return credlst ;
    }  
    
    public List<Product_EntryStatus__c> getConnection()
{
    List<Product_EntryStatus__c>Connection= [SELECT Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Connection' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c,Key_Opinion_Leader__r.Name ASC NULLS LAST];
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:Connection) {  
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
    Connection= [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Connection' and Country__c =: prod.Country__c and Product__c=: prod.Product__c  ORDER BY Order__c ASC NULLS LAST];
    
    return Connection;
    
}  
    public List<Product_EntryStatus__c> getConvinced()
{
    List<Product_EntryStatus__c> Convinced = [SELECT Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Convinced' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c,Key_Opinion_Leader__r.Name ASC NULLS LAST];
   
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:Convinced) {  
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
    Convinced= [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Convinced' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Key_Opinion_Leader__r.Name desc];
    system.debug('**********setConvinced***********'+Convinced);
    return Convinced;
    
}
    public tt(ApexPages.StandardController controller)
    {
 
        prod= new Product_EntryStatus__c();
    this.prod= (Product_EntryStatus__c )controller.getRecord();
        accLst = [select id,name,Status__c from Product_EntryStatus__c   ] ;
        conLst = [select id,Key_Opinion_Leader__r.Name,Status__c from Product_EntryStatus__c   ] ;
       kolLst  =  [select id,KOL_Title__c from Product_EntryStatus__c   ] ; 
       ordLst = [select id,Order__c from Product_EntryStatus__c   ] ;
       credlst = [SELECT id,Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Credibility' ];
       connLst = [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where  Process_Step__c ='Connection'   ];
       convLst =  [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where  Process_Step__c ='Convinced'  ];
        advoLst =   [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Process_Step__c ='Advocating'   ];
      system.debug('**********credlst ***********'+credlst);
  
        wrapper = new List<MyWrapper>() ;
        
       
      for(Integer i=0 ;i<3;i++)
            wrapper.add(new MyWrapper(accLst[i],conLst[i],kolLst[i],ordLst[i],credlst[i], connLst[i],convLst[i],advoLst[i])) ; 
    }
    
    public class MyWrapper
    {
        public Product_EntryStatus__c accRec {get; set;}
        public Product_EntryStatus__c conRec {get; set;}
        public Product_EntryStatus__c kolRec {get; set;}
        public Product_EntryStatus__c ordRec {get; set;}
        public Product_EntryStatus__c credRec {get; set;} 
         public Product_EntryStatus__c connRec {get; set;}  
          public Product_EntryStatus__c convRec {get; set;}   
           public Product_EntryStatus__c advoRec {get; set;}  
           
        public MyWrapper(Product_EntryStatus__c acc ,Product_EntryStatus__c con,Product_EntryStatus__c kol,Product_EntryStatus__c ord,Product_EntryStatus__c cred,Product_EntryStatus__c conn,Product_EntryStatus__c conv,Product_EntryStatus__c advo)
        {
            accRec = acc ;
            conRec = con ;
             kolRec =  kol ;
             ordRec = ord;
             credRec = cred;  
             connRec = conn;  
             convRec = conv; 
             advoRec = advo;     
        }
    }
}

 
The code is giving me an error.
 System.ListException: List index out of bounds: 6  Class.tt.<init>: line 14, column 1
Please help me on this.

APEX CONTROLLER
----------------------------------------------------------------
public class tt
{
    public List<Account> accLst {get; set;}
    public List<Contact> conLst {get; set;}
    public List<MyWrapper> wrapper {get; set;}

    public tt()
    {
        accLst = [select id,name from account   ] ;
        conLst = [select id,name from contact   ] ;
        wrapper = new List<MyWrapper>() ;
        for(Integer i=0 ;i<20;i++)
            wrapper.add(new MyWrapper(accLst[i] , conLst[i])) ;
    }
    
    public class MyWrapper
    {
        public Account accRec {get; set;}
        public Contact conRec {get; set;}
        
        public MyWrapper(Account acc , Contact con)
        {
            accRec = acc ;
            conRec = con ;
        }
    }
}

VisualForce Page

<apex:page controller="tt">
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockTable value="{!wrapper}" var="wrap">
                <apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
                <!-- you can add related fields here   -->
                <apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
Hi Folks,
I am trying to write test class but unable to cover code coverage beyond 48%.I am getting error while accessing inner class in my test method.Please help me to cover my code coverage atleast upto 75%.

Apex Class:
*********************************************************************
global class InboundLitmosEmailService implements Messaging.InboundEmailHandler
{
 private Map<String,Litmos_Completed_History__c> litmosComHistoryToUpsert = new Map<String,Litmos_Completed_History__c>();
    
    private Map<String,Contact> emailIdContactMap = new Map<String,Contact>();
    private Map<Id,Contact> idContactMap = new Map<Id,Contact>();
    private Map<String,User> emailIdUserMap = new Map<String,User>();
    private Map<String,Litmos_Completed_History__c> UserIDtoLimitosCompletedHistory = new Map<String,Litmos_Completed_History__c>();
  String errorMessage{get;set;}
    Boolean hasError{get;set;}  
 @TestVisible private class TargetweekDetails
    {
        public string Name;
        public integer TargetWeekNo;
        public Datetime TargetDate;
    }
  global InboundLitmosEmailService()
    {
        hasError = false;
    }
 global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
    {
      final Integer DATE_COMPLETED = 1;
        final Integer EMAIL_ID = 0;
        final Integer MODULE_STATUS = 28;
       Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        if(email.binaryAttachments != null && email.binaryAttachments.size() == 1 && (email.binaryAttachments[0].fileName.endsWith('.csv') || email.binaryAttachments[0].fileName.endsWith('.txt')))
        {                       
            for(Integer x = 0; x < email.binaryAttachments.size(); x++)
            {
                Set<String> emailIds = new Set<String>();
             String attachmentString = email.binaryAttachments[x].body.toString().replace('|',',');
                attachmentString = attachmentString.replace('"', '');
                List<String> csvRows = attachmentString.split('\n',0);
 Integer r = 0;
                for(String row : csvRows)
                {
                 errorMessage = '';
 if(r > 0)
                    {
              if(row.length() > 30)
                        {
                           List<String> rowFields = row.split(',');
                            if(rowFields[EMAIL_ID] != null)
                                emailIds.add(String.valueOf(rowFields[EMAIL_ID]));
                        }
                    }
                    r++;
                }
                System.debug('???? Email Ids'+ emailIds);
                for(Contact c : [Select Id, Program_Start_Date__c, Email From Contact Where Email IN :emailIds])
                {
                    System.debug('??? inside for loop');
                    idContactMap.put(c.Id,c);
                    emailIdContactMap.put(c.Email,c);
                }
                System.debug('????'+ idContactMap.size());
                for(User u : [Select Id, ContactId From User Where ContactId IN :idContactMap.keyset()])
                {
                    emailIdUserMap.put(idContactMap.get(u.ContactId).Email, u);
                }
               System.debug('????'+ emailIdUserMap.size());
                 for(Litmos_Completed_History__c l : [Select Id, Name, Completed__c  From Litmos_Completed_History__c Where Contact__c IN :idContactMap.keyset()])
                {
                    UserIDtoLimitosCompletedHistory.put(l.Name, l);
                }
                System.debug('????'+ UserIDtoLimitosCompletedHistory.size());
              r=0;
                map<Decimal,Decimal> GoalsMap = new map<Decimal,Decimal>();
                list<Required_Lesson__c> GoalsList = [select id, name, Lessons_Required__c, Week_Number__c from Required_Lesson__c];
                for (Required_Lesson__c theGoal : GoalsList)
                    GoalsMap.put(theGoal.Week_Number__c,theGoal.Lessons_Required__c);
              Map<String,Double> lchNameToCompletedModuleCountMap = new Map<String,Double>();
  for(String row : csvRows)
                {                
                    errorMessage = '';
                    if(r > 0)
                    {
                        if(row.length() > 30)
                        {
            List<String> rowFields = row.split(',');
                            System.debug('????'+r);
                            String emailid = rowFields[EMAIL_ID];
                            System.debug('???? Email Id '+rowFields[EMAIL_ID]);
if(rowFields[EMAIL_ID] != null && emailIdContactMap!=null && emailIdUserMap !=null && emailIdContactMap.get(rowFields[EMAIL_ID]) != null && emailIdContactMap.get(emailid).Program_Start_Date__c != null)                            
                            {
                                System.debug('????? Inside if');
                                String UserID = emailIdUserMap.get(emailid).Id;
                           Date LastAttemptDate = formatDate(rowFields[DATE_COMPLETED], 'finishdate');
                                
                                TargetweekDetails Targetweek = getTargetweekDetails(emailIdContactMap.get(emailid).Program_Start_Date__c, LastAttemptDate);
                                System.debug('????'+Targetweek.TargetWeekNo);
                                Litmos_Completed_History__c singleLitmos = new Litmos_Completed_History__c();

                                if(lchNameToCompletedModuleCountMap.get(UserID+'-'+Targetweek.TargetWeekNo) == null)
                                {
                                    lchNameToCompletedModuleCountMap.put(UserID+'-'+Targetweek.TargetWeekNo,0);
                                }
                                if(lchNameToCompletedModuleCountMap.get(singleLitmos.Name) == null)
                                {
                                    lchNameToCompletedModuleCountMap.put(singleLitmos.Name,0);
                                }
 if(UserIDtoLimitosCompletedHistory.containsKey(UserID+'-'+Targetweek.TargetWeekNo))
                                {
                                    System.debug('????? Existing');
                                    if(litmosComHistoryToUpsert.containsKey(UserID+'-'+Targetweek.TargetWeekNo))
                                        singleLitmos = litmosComHistoryToUpsert.get(UserID+'-'+Targetweek.TargetWeekNo);
                                    else
                                        singleLitmos = UserIDtoLimitosCompletedHistory.get(UserID+'-'+Targetweek.TargetWeekNo);
                                     lchNameToCompletedModuleCountMap.put(UserID+'-'+Targetweek.TargetWeekNo,lchNameToCompletedModuleCountMap.get(UserID+'-'+Targetweek.TargetWeekNo) + 1);                                        
                                   
                                    singleLitmos.Required_At_Time__c = GoalsMap.get(Targetweek.TargetWeekNo);
                                    singleLitmos.Week_Number__c = Targetweek.TargetWeekNo; 
                                    singleLitmos.Week_Start__c =  Targetweek.TargetDate;
                                    singleLitmos.Week_End__c = Targetweek.TargetDate.addDays(7);
                                 singleLitmos.Completed__c = lchNameToCompletedModuleCountMap.get(UserID+'-'+Targetweek.TargetWeekNo);
                                    litmosComHistoryToUpsert.put(UserID+'-'+Targetweek.TargetWeekNo, singleLitmos);
                                }
                                else
                                {
                                    System.debug('????? New');
                                    singleLitmos.Contact__c = emailIdContactMap.get(emailid).Id;
                                    singleLitmos.UserId__c = UserID;
                                    singleLitmos.Name = UserID+'-'+Targetweek.TargetWeekNo;
                                    singleLitmos.Required_At_Time__c = GoalsMap.get(Targetweek.TargetWeekNo);
                                    singleLitmos.Week_Number__c = Targetweek.TargetWeekNo; 
                                    singleLitmos.Week_Start__c =  Targetweek.TargetDate;
                                    singleLitmos.Week_End__c = Targetweek.TargetDate.addDays(6);
                             lchNameToCompletedModuleCountMap.put(singleLitmos.Name,lchNameToCompletedModuleCountMap.get(UserID+'-'+Targetweek.TargetWeekNo) + 1);                                                                            
                                    singleLitmos.Completed__c = lchNameToCompletedModuleCountMap.get(singleLitmos.Name);
                                    singleLitmos.Month__c = String.valueOf(Targetweek.TargetDate.month());
                                    singleLitmos.Year__c = String.valueOf(Targetweek.TargetDate.year());
                                    
                                    UserIDtoLimitosCompletedHistory.put(singleLitmos.Name,singleLitmos);
                                    litmosComHistoryToUpsert.put(UserID+'-'+Targetweek.TargetWeekNo, singleLitmos);
                                }
                             }
                       }
                    }
                    r++;
                }
     if (Test.isRunningTest()){           
            
                    Savepoint sp = Database.setSavepoint();
                    try
                        {
                            System.debug('=> printing the upsert values');
                            for(String key : litmosComHistoryToUpsert.keySet())
                            {
                                System.debug('=>key:'+key+','+'value:'+litmosComHistoryToUpsert.get(key));
                            }
                            upsert litmosComHistoryToUpsert.values();
  }
                    catch(Exception e)
                        {
                            Database.rollback(sp);
                            System.debug('////////////////// Inbound Email Exception: ' + e);                       
                            hasError = true;
                        }
                    }
            }
        }       
        result.success = !hasError;
        return result;
    }
@TestVisible private TargetweekDetails getTargetweekDetails(Date ProgramStartDate, Date LastAttempt)
    {        
        TargetweekDetails singleweek = new TargetweekDetails();
        Date referenceDate = Date.newInstance(2015, 1, 2);
        Integer diff = referenceDate.daysbetween(LastAttempt);
        Integer mod = Math.mod(diff,7);
        Date weekStartDate = LastAttempt.addDays(-mod);
        singleweek.TargetDate = weekStartDate;
        singleweek.name = 'CurrentWeek';
        singleweek.TargetWeekNo = ProgramStartDate.daysbetween(weekStartDate.addDays(8))/7;
         return singleweek;
    }
}

 
Hello,

---------TRIGGER----------

trigger UpdateReportName on ActivityPlanningAndReport__c (before insert) {
     Map<Id,User> ownerMap;
     Set<Id> oppOwnerIds = new Set<Id>();
     String nameOfOwner;
     for(ActivityPlanningAndReport__c p : trigger.new)
    {
        oppOwnerIds.add(p.OwnerId);
    }
     ownerMap = new Map<Id,User>([SELECT Id, Name FROM User WHERE Id IN :oppOwnerIds]);
     for(ActivityPlanningAndReport__c p : trigger.new)
     {
          nameOfOwner = ownerMap.get(p.OwnerId).Name;
        if(p.Name!=null)
        {
            p.Name = p.Country_txt__c+'_'+ p.Display_Engagement_Date__c+'_'+nameOfOwner;
     }
     }   
   }
Hi,

I want to insert duplicates contacts for associated accounts.
How is this possible using import tools.
I tried using jitterbit but it gives an error 'Creation of duplicate records'.
Please help me on this.
Thank you
Hello,

I have two lookup fields Company name(Account) and Contact Person(Contacts) on Visits object.Based on Company Name selected i want to filter the Contact person.

Thanks.
I have two objects Contacts and Product.
Every contact has a product associated with it and every product has a product status i.e(Awarenes,Credibility,Connection,Advocating).
I want to display the values in one column mapping the contacts(KOL Name) with each product status.
The cell color will also vary according to the status. How can i implement this.
Please help me on this .

Order    KOL - Title/ Role   KOLName         Credibility  Awareness  Connection   Advocating
1.00      MNCP Manager    Keziah Malm      P-023      P-023           P-004          P-006

APEX PAGE
--------------------------------------------------------------------------
<apex:page standardController="Product_EntryStatus__c" extensions="tt" > <apex:pageBlock > <apex:pageBlockSection > <apex:pageBlockTable value="{!wrapper}" var="wrap"> <apex:facet name="Header">Advocating</apex:facet> <apex:column headerValue="Order" value="{!wrap.ordRec.Order__c}"/> <apex:column headerValue="KOL Title" value="{!wrap.kolRec.KOL_Title__c}"/> <apex:column headerValue="KOL Name" value="{!wrap.conRec.Key_Opinion_Leader__r.Name}"/> //<apex:column headerValue="Credibility" value="{!wrap.credRec.Name}"/> <apex:column headerValue="Awareness" value="{!wrap.accRec.Name}"/> <apex:column headerValue="Connection" value="{!wrap.connRec.Name}"/> <apex:column headerValue="Advocating" value="{!wrap.advoRec.Name}"/> <!-- you can add related fields here --> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:page>

APEX CLASS
------------------------------------------------------------------------
public class tt
{

   


   

 public Product_EntryStatus__c prod; 
    public List<Product_EntryStatus__c> accLst {get; set;}
    public List<Product_EntryStatus__c> conLst {get; set;}
    public List<Product_EntryStatus__c> kolLst {get; set;}
     public List<Product_EntryStatus__c> ordLst {get; set;}
     public List<Product_EntryStatus__c> credlst{get;set;}
     public List<Product_EntryStatus__c> connlst{get;set;}
       public List<Product_EntryStatus__c> convlst{get;set;}
        public List<Product_EntryStatus__c> advolst{get;set;}
   
   
    public List<MyWrapper> wrapper {get; set;}
    
    public List<Product_EntryStatus__c> getAdvocating()
{
    List<Product_EntryStatus__c> Advocating = [SELECT Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Advocating' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c,Key_Opinion_Leader__r.Name DESC NULLS LAST];
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:Advocating) {  
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
    Advocating= [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Advocating' and Country__c =: prod.Country__c and Product__c=: prod.Product__c  ORDER BY Order__c,Key_Opinion_Leader__r.Name DESC NULLS LAST];
    
    return Advocating;
    
}
    
    public List<Product_EntryStatus__c> getCredibility()
    {
    List<Product_EntryStatus__c>credlst= [SELECT id,Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Credibility' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c  ASC NULLS LAST];
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:credlst) {
 
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
     credlst = [SELECT id,Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Credibility' and Country__c =: prod.Country__c and Product__c=: prod.Product__c  ORDER BY Order__c ASC];
    
    return credlst ;
    }  
    
    public List<Product_EntryStatus__c> getConnection()
{
    List<Product_EntryStatus__c>Connection= [SELECT Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Connection' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c,Key_Opinion_Leader__r.Name ASC NULLS LAST];
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:Connection) {  
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
    Connection= [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Connection' and Country__c =: prod.Country__c and Product__c=: prod.Product__c  ORDER BY Order__c ASC NULLS LAST];
    
    return Connection;
    
}  
    public List<Product_EntryStatus__c> getConvinced()
{
    List<Product_EntryStatus__c> Convinced = [SELECT Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Convinced' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Order__c,Key_Opinion_Leader__r.Name ASC NULLS LAST];
   
    List<String> setName = new List<String>();
 
    for (Product_EntryStatus__c pe:Convinced) {  
     setName.add(pe.Key_Opinion_Leader__r.Name);
    }
    system.debug('**********setName***********'+setName);
    Convinced= [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Key_Opinion_Leader__r.Name in:setName and Process_Step__c ='Convinced' and Country__c =: prod.Country__c and Product__c=: prod.Product__c order by Key_Opinion_Leader__r.Name desc];
    system.debug('**********setConvinced***********'+Convinced);
    return Convinced;
    
}
    public tt(ApexPages.StandardController controller)
    {
 
        prod= new Product_EntryStatus__c();
    this.prod= (Product_EntryStatus__c )controller.getRecord();
        accLst = [select id,name,Status__c from Product_EntryStatus__c   ] ;
        conLst = [select id,Key_Opinion_Leader__r.Name,Status__c from Product_EntryStatus__c   ] ;
       kolLst  =  [select id,KOL_Title__c from Product_EntryStatus__c   ] ; 
       ordLst = [select id,Order__c from Product_EntryStatus__c   ] ;
       credlst = [SELECT id,Name,Status__c,Country__c,Product__c,Key_Opinion_Leader__r.Name FROM Product_EntryStatus__c where Process_Step__c ='Credibility' ];
       connLst = [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where  Process_Step__c ='Connection'   ];
       convLst =  [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where  Process_Step__c ='Convinced'  ];
        advoLst =   [SELECT Name,Status__c,Country__c,Product__c,KOL_Title__c,Key_Opinion_Leader__c FROM Product_EntryStatus__c where Process_Step__c ='Advocating'   ];
      system.debug('**********credlst ***********'+credlst);
  
        wrapper = new List<MyWrapper>() ;
        
       
      for(Integer i=0 ;i<3;i++)
            wrapper.add(new MyWrapper(accLst[i],conLst[i],kolLst[i],ordLst[i],credlst[i], connLst[i],convLst[i],advoLst[i])) ; 
    }
    
    public class MyWrapper
    {
        public Product_EntryStatus__c accRec {get; set;}
        public Product_EntryStatus__c conRec {get; set;}
        public Product_EntryStatus__c kolRec {get; set;}
        public Product_EntryStatus__c ordRec {get; set;}
        public Product_EntryStatus__c credRec {get; set;} 
         public Product_EntryStatus__c connRec {get; set;}  
          public Product_EntryStatus__c convRec {get; set;}   
           public Product_EntryStatus__c advoRec {get; set;}  
           
        public MyWrapper(Product_EntryStatus__c acc ,Product_EntryStatus__c con,Product_EntryStatus__c kol,Product_EntryStatus__c ord,Product_EntryStatus__c cred,Product_EntryStatus__c conn,Product_EntryStatus__c conv,Product_EntryStatus__c advo)
        {
            accRec = acc ;
            conRec = con ;
             kolRec =  kol ;
             ordRec = ord;
             credRec = cred;  
             connRec = conn;  
             convRec = conv; 
             advoRec = advo;     
        }
    }
}

 
The code is giving me an error.
 System.ListException: List index out of bounds: 6  Class.tt.<init>: line 14, column 1
Please help me on this.

APEX CONTROLLER
----------------------------------------------------------------
public class tt
{
    public List<Account> accLst {get; set;}
    public List<Contact> conLst {get; set;}
    public List<MyWrapper> wrapper {get; set;}

    public tt()
    {
        accLst = [select id,name from account   ] ;
        conLst = [select id,name from contact   ] ;
        wrapper = new List<MyWrapper>() ;
        for(Integer i=0 ;i<20;i++)
            wrapper.add(new MyWrapper(accLst[i] , conLst[i])) ;
    }
    
    public class MyWrapper
    {
        public Account accRec {get; set;}
        public Contact conRec {get; set;}
        
        public MyWrapper(Account acc , Contact con)
        {
            accRec = acc ;
            conRec = con ;
        }
    }
}

VisualForce Page

<apex:page controller="tt">
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockTable value="{!wrapper}" var="wrap">
                <apex:column headerValue="Account Name" value="{!wrap.accRec.Name}"/>
                <!-- you can add related fields here   -->
                <apex:column headerValue="Contact Name" value="{!wrap.conRec.Name}"/>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>