• dnvansant
  • NEWBIE
  • 55 Points
  • Member since 2011

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

If DD/MM/YYYY is the date format in the csv file, then the date loaded in salesforce is unbelievably different…!

Ex: 26/10/2011 is the date in my csv file and the date is loaded in salesforce as- 2/10/2013 ..

what makes such a huge difference???

Is it like csv file doesn’t support this date format?

somebody pls respond.. 

I've tried all versions of data loader between 19 and 22.

 

Regards,

Anil

(anilcvm@yahoo.in)

  • October 21, 2011
  • Like
  • 0

It only has 1 query in a map which is not in a loop. Does "get" count as a query?

 

FYI, this works when updating Accounts in batches of 20 but not in batches of 50 or more.

 

 

trigger Territory on Account (after insert, after update) {

List<Account> ac = new List<Account>();
public list<string> name = new List<string>();

for(integer j=0; j < trigger.new.size();j++){
name.add(trigger.new[j].territory_OEM__c);  
name.add(trigger.new[j].territory_Direct__c); }

Map<String,String> territory = new Map<String,String>();
for (Territory__c t :[SELECT name, owner__c from Territory__c where name in :name])
{territory.put(t.name, t.Owner__c);}

for(integer i=0; i < trigger.new.size();i++){
If(
trigger.isinsert || (trigger.isupdate

&& (trigger.new[i].Temp__c == 62 && trigger.old[i].Temp__c != 62 ||
trigger.new[i].billingcountry != trigger.old[i].billingcountry ||
trigger.new[i].billingstate != trigger.old[i].billingstate ||
trigger.new[i].billingpostalcode != trigger.old[i].billingpostalcode ||
trigger.new[i].company_size__c != trigger.old[i].company_size__c
))

){
if(Territory.containsKey(trigger.new[i].Territory_OEM__c) && Territory.containsKey(trigger.new[i].Territory_Direct__c)){
ac.add(new account(
ID = trigger.new[i].ID,
territory_owner_OEM__c = territory.get(trigger.new[i].Territory_OEM__c),
territory_owner_direct__c = territory.get(trigger.new[i].Territory_Direct__c)
));else{}
}

if(ac.size() > 0){update ac;}else{}

}else{}}}

 

I'm getting this error message:

 

"System.LimitException: Too many query rows: 50001", Failure Stack Trace: "(System Code) Trigger.TimeSeries: line 6, column 1"

 

Line 6 on Trigger.TimeSeries is not within a loop and queries an obect with only 10,000 records. So how am I exceeding 50,000 rows?

 

Is it possible that 50,000 refers to the sum of several different queries, but that it's just the TimeSeries query that pushes the total over 50,000?

 

Can any one tell me why the code below would return the value

 

8/1/2012 8:00 PM
when the code was executed at

 

8/2/2012 3:38 PM EDT

 

The code was executed in the sandbox by a user in the EDT timezone.

 

LeadsToUpdate.add(new Lead(Id=l.id, Date_Demo__c = Date.today()))

 

I think the issue is the SOQL in the for statement, but I'm having issues trying to put this kind of SOQL Count in a map. I'm assuming some sort of mapping is required to get around my too many queries issue.

 

Can someone please point me in the right direction?

 

 

trigger StarRatingCampaign on CampaignMember (after insert)
{
Set<Id> leadId = new Set<Id>();

for (CampaignMember cm : trigger.new){leadId.add(cm.CampaignId);

Integer i = [SELECT count() FROM CampaignMember where CampaignId != '701C0000000ZFdA' and CampaignId=:Leadid and (Star_RatingF__c = '5' OR Star_RatingF__c = '4')];

Campaign newCampaign = new Campaign(id=cm.campaignid, Total_5_4_Star_Leads__c = i );
update newCampaign;}
}

On an opportunity trigger, I want to update the oldest campaignmember that is related to a contactrole that is related to the trigger opportunity. I assume I can get the oldest campaignmember with a sort and limit, but I'm having trouble getting the ID for that campaignmember because I can't figure out how to link three relationships together (CampaignMember ==> ContactRole ==> Opportunity).

 

Anyone know how to do this efficiently?

 

Thank you.

 

-Derek



I'm not sure this is even possible. I want to fire a trigger any time an opportunity is edited. For the trigger opportunity, I want to find all opportunities with the same AccountID and then populate the ASP__c field on all matching opportunities with the sum of the Amount field for those matching opportunities. The code below does this beautifully for the trigger opportunity, but every attempt I make to update all other opportunities with the same AccountID results in a self reference error.

 

CODE FOR UPDATING TRIGGER OPPORTUNITY ONLY

 

trigger ASP On Opportunity (before update){
    public Id accid;
    public Id oppid;
       
for(Opportunity p : Trigger.new){
accid = p.AccountId;
oppid = p.Id;

if(p.isclosed == False)

{
List<AggregateResult> groupedResults = [SELECT sum(Amount)aver FROM Opportunity where AccountId=:accid];
Decimal decimalRevenue = 0 ;
if(groupedResults.size() > 0)
{
    String str = '' + groupedResults[0].get('aver') ;
    decimalRevenue = Decimal.ValueOf(str) ;
    System.debug('decimalRevenue ::::: ' + decimalRevenue) ;
}

p.ASP__c = decimalRevenue;
p.ASP_Count__c = [SELECT Count()FROM Opportunity where AccountId=:accid];
p.ASp_updated__c = True;

}}}

 

 

BELOW IS THE CODE I TRIED FOR ALL OPPORTUNITIES THAT PRODUCED THE SELF REFERENCE ERROR

 

trigger ASP On Opportunity (before update){
    public Id accid;
    public Id oppid;
    public list<opportunity> LeadsToUpdate = new List<opportunity>();
       
for(Opportunity p : Trigger.new){
accid = p.AccountId;
oppid = p.Id;

if(p.isclosed == False)

{
List<AggregateResult> groupedResults = [SELECT sum(Amount)aver FROM Opportunity where AccountId=:accid];
Decimal decimalRevenue = 0 ;
if(groupedResults.size() > 0)
{
    String str = '' + groupedResults[0].get('aver') ;
    decimalRevenue = Decimal.ValueOf(str) ;
    System.debug('decimalRevenue ::::: ' + decimalRevenue) ;
}

p.ASP__c = decimalRevenue;
p.ASP_Count__c = [SELECT Count()FROM Opportunity where AccountId=:accid];
p.ASp_updated__c = True;

for(Opportunity o: [Select o.Id, o.amount, o.asp__c From opportunity o where AccountId=:accid and ID!=:oppid])
LeadsToUpdate.add(new Opportunity(Id=o.Id, ASP__c = decimalRevenue));
if(LeadsToUpdate.size()>0){update LeadsToUpdate;}
}}}

 

 

Anyone got any ideas for updating all opportunities with the same AccountID without self referencing the trigger opportunity or creating an infinite loop?

It only has 1 query in a map which is not in a loop. Does "get" count as a query?

 

FYI, this works when updating Accounts in batches of 20 but not in batches of 50 or more.

 

 

trigger Territory on Account (after insert, after update) {

List<Account> ac = new List<Account>();
public list<string> name = new List<string>();

for(integer j=0; j < trigger.new.size();j++){
name.add(trigger.new[j].territory_OEM__c);  
name.add(trigger.new[j].territory_Direct__c); }

Map<String,String> territory = new Map<String,String>();
for (Territory__c t :[SELECT name, owner__c from Territory__c where name in :name])
{territory.put(t.name, t.Owner__c);}

for(integer i=0; i < trigger.new.size();i++){
If(
trigger.isinsert || (trigger.isupdate

&& (trigger.new[i].Temp__c == 62 && trigger.old[i].Temp__c != 62 ||
trigger.new[i].billingcountry != trigger.old[i].billingcountry ||
trigger.new[i].billingstate != trigger.old[i].billingstate ||
trigger.new[i].billingpostalcode != trigger.old[i].billingpostalcode ||
trigger.new[i].company_size__c != trigger.old[i].company_size__c
))

){
if(Territory.containsKey(trigger.new[i].Territory_OEM__c) && Territory.containsKey(trigger.new[i].Territory_Direct__c)){
ac.add(new account(
ID = trigger.new[i].ID,
territory_owner_OEM__c = territory.get(trigger.new[i].Territory_OEM__c),
territory_owner_direct__c = territory.get(trigger.new[i].Territory_Direct__c)
));else{}
}

if(ac.size() > 0){update ac;}else{}

}else{}}}

 

I'm getting this error message:

 

"System.LimitException: Too many query rows: 50001", Failure Stack Trace: "(System Code) Trigger.TimeSeries: line 6, column 1"

 

Line 6 on Trigger.TimeSeries is not within a loop and queries an obect with only 10,000 records. So how am I exceeding 50,000 rows?

 

Is it possible that 50,000 refers to the sum of several different queries, but that it's just the TimeSeries query that pushes the total over 50,000?

 

Can any one tell me why the code below would return the value

 

8/1/2012 8:00 PM
when the code was executed at

 

8/2/2012 3:38 PM EDT

 

The code was executed in the sandbox by a user in the EDT timezone.

 

LeadsToUpdate.add(new Lead(Id=l.id, Date_Demo__c = Date.today()))

 

I think the issue is the SOQL in the for statement, but I'm having issues trying to put this kind of SOQL Count in a map. I'm assuming some sort of mapping is required to get around my too many queries issue.

 

Can someone please point me in the right direction?

 

 

trigger StarRatingCampaign on CampaignMember (after insert)
{
Set<Id> leadId = new Set<Id>();

for (CampaignMember cm : trigger.new){leadId.add(cm.CampaignId);

Integer i = [SELECT count() FROM CampaignMember where CampaignId != '701C0000000ZFdA' and CampaignId=:Leadid and (Star_RatingF__c = '5' OR Star_RatingF__c = '4')];

Campaign newCampaign = new Campaign(id=cm.campaignid, Total_5_4_Star_Leads__c = i );
update newCampaign;}
}

On an opportunity trigger, I want to update the oldest campaignmember that is related to a contactrole that is related to the trigger opportunity. I assume I can get the oldest campaignmember with a sort and limit, but I'm having trouble getting the ID for that campaignmember because I can't figure out how to link three relationships together (CampaignMember ==> ContactRole ==> Opportunity).

 

Anyone know how to do this efficiently?

 

Thank you.

 

-Derek



If DD/MM/YYYY is the date format in the csv file, then the date loaded in salesforce is unbelievably different…!

Ex: 26/10/2011 is the date in my csv file and the date is loaded in salesforce as- 2/10/2013 ..

what makes such a huge difference???

Is it like csv file doesn’t support this date format?

somebody pls respond.. 

I've tried all versions of data loader between 19 and 22.

 

Regards,

Anil

(anilcvm@yahoo.in)

  • October 21, 2011
  • Like
  • 0

I'm not sure this is even possible. I want to fire a trigger any time an opportunity is edited. For the trigger opportunity, I want to find all opportunities with the same AccountID and then populate the ASP__c field on all matching opportunities with the sum of the Amount field for those matching opportunities. The code below does this beautifully for the trigger opportunity, but every attempt I make to update all other opportunities with the same AccountID results in a self reference error.

 

CODE FOR UPDATING TRIGGER OPPORTUNITY ONLY

 

trigger ASP On Opportunity (before update){
    public Id accid;
    public Id oppid;
       
for(Opportunity p : Trigger.new){
accid = p.AccountId;
oppid = p.Id;

if(p.isclosed == False)

{
List<AggregateResult> groupedResults = [SELECT sum(Amount)aver FROM Opportunity where AccountId=:accid];
Decimal decimalRevenue = 0 ;
if(groupedResults.size() > 0)
{
    String str = '' + groupedResults[0].get('aver') ;
    decimalRevenue = Decimal.ValueOf(str) ;
    System.debug('decimalRevenue ::::: ' + decimalRevenue) ;
}

p.ASP__c = decimalRevenue;
p.ASP_Count__c = [SELECT Count()FROM Opportunity where AccountId=:accid];
p.ASp_updated__c = True;

}}}

 

 

BELOW IS THE CODE I TRIED FOR ALL OPPORTUNITIES THAT PRODUCED THE SELF REFERENCE ERROR

 

trigger ASP On Opportunity (before update){
    public Id accid;
    public Id oppid;
    public list<opportunity> LeadsToUpdate = new List<opportunity>();
       
for(Opportunity p : Trigger.new){
accid = p.AccountId;
oppid = p.Id;

if(p.isclosed == False)

{
List<AggregateResult> groupedResults = [SELECT sum(Amount)aver FROM Opportunity where AccountId=:accid];
Decimal decimalRevenue = 0 ;
if(groupedResults.size() > 0)
{
    String str = '' + groupedResults[0].get('aver') ;
    decimalRevenue = Decimal.ValueOf(str) ;
    System.debug('decimalRevenue ::::: ' + decimalRevenue) ;
}

p.ASP__c = decimalRevenue;
p.ASP_Count__c = [SELECT Count()FROM Opportunity where AccountId=:accid];
p.ASp_updated__c = True;

for(Opportunity o: [Select o.Id, o.amount, o.asp__c From opportunity o where AccountId=:accid and ID!=:oppid])
LeadsToUpdate.add(new Opportunity(Id=o.Id, ASP__c = decimalRevenue));
if(LeadsToUpdate.size()>0){update LeadsToUpdate;}
}}}

 

 

Anyone got any ideas for updating all opportunities with the same AccountID without self referencing the trigger opportunity or creating an infinite loop?