• Sarath Addanki
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hello everyone!

I have a trigger (below) that is excluding the User Role 'Research' so that role can perform bulk updates on that object. The triggers works fine when you update individual records and up to 100 records for bulk updates. If we exceed 100 records for our bulk updates we receive the following error:

 System.LimitException: Too many SOQL queries: 101

Any assistance with this trigger is greatly appreciated!!
trigger SurveyHandling on Relationship_to_Initiative_Research__c (after insert,after delete,after update) {

list<Id> rlist4=new list<Id> ();
list<Initiatives__c > rlsit5=new list<Initiatives__c >();

//////////// insert and update operation


if(trigger.isinsert || trigger.isupdate){
for(Relationship_to_Initiative_Research__c i : trigger.new)


{UserInfo.getUserRoleId(); 

List<String> exemptedRoles = new List<String>();
exemptedRoles.add('ATeam');

list<UserRole> IsItExemptedRole=[select id,name from UserRole where name in :exemptedRoles and id=:UserInfo.getUserRoleId()];

if(IsItExemptedRole.size()<=0){


{

rlist4.add(i.Initiative_Title__c );     
}


Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c,Progress__c,Timeframe__c,Owner__c from Initiatives__c where id in:rlist4];


for(Relationship_to_Initiative_Research__c rr:trigger.new){

ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ;
ini.Progress__c=rr.Progress__c ;
ini.Timeframe__c=rr.Timeframe__c ;
ini.Owner__c=rr.Owner__c ;


rlsit5.add(ini);
} update rlsit5; 

}


/////////////// Delete operation start   




if(trigger.isdelete){
for(Relationship_to_Initiative_Research__c ii : trigger.old)

{

rlist4.add(ii.Initiative_Title__c );     
}


Initiatives__c ini=[select id,Action_ItemsRICHTEXT__c,Progress__c,Timeframe__c,Owner__c  from Initiatives__c where id in:rlist4];


for(Relationship_to_Initiative_Research__c rr:trigger.old){

ini.Action_ItemsRICHTEXT__c=rr.Action_Item_ScriptRICHTEXT__c ;
ini.Progress__c=rr.Progress__c ;
ini.Timeframe__c=rr.Timeframe__c ;
ini.Owner__c=rr.Owner__c ;
rlsit5.add(ini);
} update rlsit5; 

}


}
}
}

 
  • March 13, 2018
  • Like
  • 0
Hello,
I have a custom object called "Line Item", that has a master-detail relationship on Opportunity.
On an opportunity, I can have multiple "Line items". Each line item has a value.

I would like to multiply these values, and get the result in a field on opportunity.

Example:
"My opportunity":
  • Line item 1: 2
  • Line item 2: 10
  • Line item 3: 2

Field "my multiplication" on "My opportunity": 2*10*2=40

What I'm trying to achieve is actually a custom field with a field type "Roll up summary", but Salesforce only allows to calcualte Min, Max, Count, Sum...

Any ideas how I can achieve this?