• RishiKalia
  • NEWBIE
  • 55 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies

So, I am getting this:

Error: Invalid Data.
TasksOutlookTaskUpdate: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0: Trigger.TasksOutlookTaskUpdate: line 7, column 1 ...

... when I try to use certain accounts/contacts/opportunities.  It seems like accounts/contacts/opportunities created before a certain hour today, show up in the query making the trigger function; but after a certain time today, there is nothing but failure.  I've tried to mess around with it, but have come up with nothing ... any help would be appreciated!

Here's the code:

trigger TasksOutlookTaskUpdate on Task (before insert, before update) {
    String TaskType = trigger.new[0].Type;
    Id WhoIDCheck = trigger.new[0].WhoId;
    Id WhatIDCheck = trigger.new[0].WhatId;
    List<Task> RefName = [SELECT What.Type, What.Name FROM Task WHERE WhatId = :WhatIDCheck];
    List<Task> WhoNum = [SELECT Who.Type FROM Task WHERE WhoId = :WhoIDCheck];
    If ( WhoNum[0].Who.Type == 'Contact' ) {
        List<Contact> ContData = [SELECT Name, Phone, Email FROM Contact WHERE Id = :WhoIDCheck];
        String TaskID = trigger.new[0].Id;
        string ForOutlook = 'Type: ' + TaskType + '\n' + 'Related To: ' + RefName[0].What.Type + ': '
        + RefName[0].What.Name + '\n'
        + 'Contact: ' + ContData[0].Name + '\n' + 'Phone: ' + ContData[0].Phone + '\n' + 'Email: ' + ContData[0].Email + '\n';
        // + 'Link to Activity: https://na6.salesforce.com/' + TaskID
        trigger.new[0].TMP_Outlook_Reference__c = ForOutlook;
    } else if ( WhoNum[0].Who.Type == 'Lead' ) {
        List<Lead> LeadData = [SELECT Name, Phone, Email FROM Lead WHERE Id = :WhoIDCheck];
        String TaskID = trigger.new[0].Id;
        string ForOutlook = 'Type: ' + TaskType + '\n' + 'Related To: ' + RefName[0].What.Type + ': '
        + RefName[0].What.Name + '\n'
        + 'Contact: ' + LeadData[0].Name + '\n' + 'Phone: ' + LeadData[0].Phone + '\n' + 'Email: ' + LeadData[0].Email + '\n';
        // + 'Link to Activity: https://na6.salesforce.com/' + TaskID;
        trigger.new[0].TMP_Outlook_Reference__c = ForOutlook;
    }
}

thanks!

  • October 22, 2012
  • Like
  • 0

Hi,

 

I've been looking for any limitation on the following issues... I'll appreciate any assistance.

 

1. Is it possible to trigger an event after insert or update a "Chatter Free" user records?

2. Is it possible to attach the Chatter Free user profile photo to a specific contact record? As an Attachment!

 

Many thanks

 

David

Hi, 

 

How to write a code for Email validation in apex class ....

 

this is my page

============

<apex:page controller="JstestController">
<apex:form id="myform">
<apex:pagemessages />
<apex:pageBlock id="myblock">
Email Address: <apex:inputText value="{!email}" id="email"/><br/><br/>
<apex:commandButton value="Click me!" action="{!checkEmail}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

 

class

.....................

 

public class JstestController
{
public String email { get; set; }
public PageReference checkEmail()
{

}

}

 

how to wrete email validation for input text  field ....

help me.......

 

  • October 29, 2012
  • Like
  • 0

hi , 

 

how to do emil validation using regular expression in apex class .....

 

how to write a code ......

 

please help me

  • October 26, 2012
  • Like
  • 0

Hoping to get some help here;  we wrote an Apex Trigger to populate a field in Opportunties with a calculation based on the record Owner's role.  It works fine for new or updated records but I can only update the existing records 50 at a time because of the SOQL limits.  Does anyone know a better way to write this code so it isn't using SOQL querries or is there a way to update mass records without hitting those limits?

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
trigger OppDepartmentUpdate on Opportunity (before insert, before update)
{
 
List<Opportunity> oppList = new List<Opportunity>();
//Opportunity[] assetList = Trigger.new;
 
  for(Opportunity opp : Trigger.New) {
   System.debug('start'); 
   String ownerId = opp.ownerId;
   List<User> users = [select UserRoleId from User where Id= :ownerId];
   String userRole;
   for(User u : users){
       System.debug('userRoleId:');
       System.debug(u.UserRoleId);
       List<UserRole> userRoles = [select Name from UserRole where Id= :u.UserRoleId];
       for(UserRole ur : userRoles){
           System.debug('userRole:');
           System.debug(ur.Name);
           userRole = ur.Name;
       }
   }
   
   System.debug(opp.Owner.UserRole);
       if((userRole=='Director-Sales')
       ||(userRole=='Sales Manager')
       ||(userRole=='Sales Generalist-AE')
       ||(userRole=='Sales Generalist-ISR')
       ||(userRole=='Sales Generalist-SE'))
    {
             opp.Department__c = 'Sales';
             oppList.add(opp);
       }
      else{
      
             opp.Department__c = 'Support';
             oppList.add(opp);
     }
  }
  //if(oppList.size() > 0 ) {
    // Database.update(oppList, false);
   //}
}

 

So, I am getting this:

Error: Invalid Data.
TasksOutlookTaskUpdate: execution of BeforeInsert caused by: System.ListException: List index out of bounds: 0: Trigger.TasksOutlookTaskUpdate: line 7, column 1 ...

... when I try to use certain accounts/contacts/opportunities.  It seems like accounts/contacts/opportunities created before a certain hour today, show up in the query making the trigger function; but after a certain time today, there is nothing but failure.  I've tried to mess around with it, but have come up with nothing ... any help would be appreciated!

Here's the code:

trigger TasksOutlookTaskUpdate on Task (before insert, before update) {
    String TaskType = trigger.new[0].Type;
    Id WhoIDCheck = trigger.new[0].WhoId;
    Id WhatIDCheck = trigger.new[0].WhatId;
    List<Task> RefName = [SELECT What.Type, What.Name FROM Task WHERE WhatId = :WhatIDCheck];
    List<Task> WhoNum = [SELECT Who.Type FROM Task WHERE WhoId = :WhoIDCheck];
    If ( WhoNum[0].Who.Type == 'Contact' ) {
        List<Contact> ContData = [SELECT Name, Phone, Email FROM Contact WHERE Id = :WhoIDCheck];
        String TaskID = trigger.new[0].Id;
        string ForOutlook = 'Type: ' + TaskType + '\n' + 'Related To: ' + RefName[0].What.Type + ': '
        + RefName[0].What.Name + '\n'
        + 'Contact: ' + ContData[0].Name + '\n' + 'Phone: ' + ContData[0].Phone + '\n' + 'Email: ' + ContData[0].Email + '\n';
        // + 'Link to Activity: https://na6.salesforce.com/' + TaskID
        trigger.new[0].TMP_Outlook_Reference__c = ForOutlook;
    } else if ( WhoNum[0].Who.Type == 'Lead' ) {
        List<Lead> LeadData = [SELECT Name, Phone, Email FROM Lead WHERE Id = :WhoIDCheck];
        String TaskID = trigger.new[0].Id;
        string ForOutlook = 'Type: ' + TaskType + '\n' + 'Related To: ' + RefName[0].What.Type + ': '
        + RefName[0].What.Name + '\n'
        + 'Contact: ' + LeadData[0].Name + '\n' + 'Phone: ' + LeadData[0].Phone + '\n' + 'Email: ' + LeadData[0].Email + '\n';
        // + 'Link to Activity: https://na6.salesforce.com/' + TaskID;
        trigger.new[0].TMP_Outlook_Reference__c = ForOutlook;
    }
}

thanks!

  • October 22, 2012
  • Like
  • 0

Hi,

 

I've been looking for any limitation on the following issues... I'll appreciate any assistance.

 

1. Is it possible to trigger an event after insert or update a "Chatter Free" user records?

2. Is it possible to attach the Chatter Free user profile photo to a specific contact record? As an Attachment!

 

Many thanks

 

David