-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
6Questions
-
4Replies
Customer portal users see all cases
Greetings!
I'm setting up a Customer Community for my clients to access my instance of salesforce to open and track their own Cases. I went through he setup steps outlined to enable users and was in the process of testing the visibility of community users to their cases (where they are the contact on the case) and discovered that while logged in as a community user I can see all cases, and can open the records.
Is there a permission setting for Customer Community I am missing?
- klocwork
- September 25, 2013
- Like
- 0
- Continue reading or reply
Trigger Help: Too many code statements
Greetings!
I've been backwards and forwards through the forums here looking at the examples of solutions to "System.LimitException: Too many code statements: 200001" errors and have made a number of the suggested modifications (that I can figure out) to my code below. I am easily able to update a handful of records, but as soon as I try to push 50 or more through the trigger I get the error.
I am swimming in the deep end and beyond my current comfort. I would sincerely appreciate some input and guidance on how I can best address the issue I'm seeing!
The intent of this code is to align the OwnerId of all related Leads and Contacts when an Account either has a new Owner assigned, or when a check box is selected. Stipulations - the Account and the Lead records must have North American Country values.
Thanks
trigger Account_ChangeOwner on Account (before update) { //This trigger updates Lead and Contact Owners based on either a new Account Owner or a selected check box integer counter=0; Set<Id> AccountIds = new Set<Id>(); For (Account Obj : trigger.new){ //Only applies to North American Accounts if (Obj.BillingCountry!=null && ( Obj.BillingCountry=='CA' || Obj.BillingCountry=='US' || Obj.BillingCountry=='Canada' || Obj.BillingCountry=='United States') ) { if (Obj.OwnerId!=trigger.old[counter].OwnerId) { AccountIds.add(Obj.Id); } else if (Obj.Reset_Contact_Owners__c==true) { AccountIds.add(Obj.Id); } } counter++; }//end of loop 1 //Gather all relevant Leads and Conacts and add them to Lists list<Lead> Lead_list = [Select l.Id, l.Account_Record__c, l.OwnerId From Lead l where l.IsDeleted=false and l.IsConverted=false //Only applies to North American Leads and (l.Country!=null and ( l.Country='CA' or l.Country='US' or l.Country='Canada' or l.Country='United States')) and Account_Record__c IN :AccountIds]; list<Contact> Contact_list = [Select c.Id, c.AccountId, c.OwnerId From Contact c where c.IsDeleted=false and AccountId IN :AccountIds]; //Make the changes counter=0; For (Account Obj : trigger.new){ if (Obj.OwnerId!=trigger.old[counter].OwnerId || Obj.Reset_Contact_Owners__c==true){ //Review the Leads and Contacts for the Acounts and change the Owner; For (Lead MyLead : Lead_list){ if (MyLead.Account_Record__c==Obj.Id){ if (Obj.Named_Account__c==true){ MyLead.OwnerId=Obj.OwnerId; } } } { For (Contact MyContact : Contact_list){ if (MyContact.AccountId==Obj.Id){ MyContact.OwnerId=Obj.OwnerId; } } } } //Clear the Reset Contact Owners field if (Obj.Reset_Contact_Owners__c==true){ Obj.Reset_Contact_Owners__c=false; } counter++; }//end of loop 2 //Process Leads Lead[] LeadsToUpdate=new Lead[]{}; For (Lead MyLead : Lead_list){ LeadsToUpdate.add(MyLead); if (LeadsToUpdate.size()==5000){ update LeadsToUpdate; LeadsToUpdate.clear(); } } if (LeadsToUpdate.size()>0){ update LeadsToUpdate; } //Process Contacts Contact[] ContactsToUpdate=new Contact[]{}; For (Contact MyContact : Contact_list){ ContactsToUpdate.add(MyContact); if (ContactsToUpdate.size()==5000){ update ContactsToUpdate; ContactsToUpdate.clear(); } } if (ContactsToUpdate.size()>0){ update ContactsToUpdate; } }//end of trigger
- klocwork
- June 03, 2013
- Like
- 0
- Continue reading or reply
Unexpected Identifier error in JavaScript button
I am spinning my wheels on this and completely stumped. When I try this code I get "A problem with the OnClick JavaScript for this button or link was encountered: Unexpected identifier".
What I am trying to do is update a custom object (Sales_Cycle__c) and the Lead record that it relates to (Sales_Cycle__c.Lead__c).
Any help would be greatly appreciated!
Thank you.
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")} var CycleUpdate = new sforce.SObject("Sales_Cycle__c"); var l = SELECT Id, Status FROM Lead where Id =\'"+ CycleUpdate.Lead__c + "\' limit 1"; CycleUpdate.Id='{!Sales_Cycle__c.Id }'; CycleUpdate.Sales_Cycle_Status__c = 'No Further Interest'; CycleUpdate.Date_Sales_Cycle_Ended__c = new Date(); l.Status = 'No Further Interest'; update CycleUpdate; update l; window.location.reload();
- klocwork
- May 13, 2013
- Like
- 0
- Continue reading or reply
Checking for null value is not returning results
Spinning my wheels on this. I'm not an APEX coder but this problem is within my skill set.
I am trying to check to see if "Account_Record__c" on "Lead" is null - and then insert a record if it is. No errors when I save the code, but when I test none of the records are behaving as expected! In my test records there are no values in "Account_Record__c" yet the related object record is not created. If I remove the "&& newLead.Account_Record__c==null" element then the related record is created.
What am I missing?
trigger createSalesAssignment on Lead (after update) { List<Sales_Assignment__c> sa = new List<Sales_Assignment__c>(); for (Lead newLead: Trigger.New) if (newLead.Status == 'Sales Ready' && newLead.Account_Record__c==null){ sa.add (new Sales_Assignment__c( Lead__c = newLead.Id)); } insert sa; }
- klocwork
- August 10, 2012
- Like
- 0
- Continue reading or reply
Works in sandbox but fails @ Validation in Production
Help please ...
Working on my 3rd ever trigger and I am having a mysterious issue.
I've used this code twice before with no incident to roll up counts from related objects. When I modified this code to update Case with a count of Comments it works fine in my sandbox, but when I validate it in Production I get the following:"Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TicketRollUpCountPublicComments: execution of AfterInsert caused by: System.QueryException: Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch Trigger..."
Is there an obvious error I am not seeing? Any thoughts would be awesome!
trigger TicketRollUpCountPublicComments on CaseComment (after insert, after update) {
set<Id> ParentIds = new set<Id>();
if(trigger.isInsert || trigger.isUpdate){
for(CaseComment c : trigger.new){
ParentIds.add(c.ParentId);
}
}
if(trigger.isDelete){
for(CaseComment c:trigger.old){
ParentIds.add(c.ParentId);
}
}
map<Id,Double> CaseMap = new map <Id,Double>();
for(aggregateResult q:[select count(Id), ParentID
from CaseComment where (CaseComment.IsPublished != FALSE) group by ParentId]){
CaseMap.put((Id)q.get('ParentId'),(Double)q.get('expr0'));
}
List<Case> CasesToUpdate = new List<Case>();
for(Case cs:[Select ID, Number_of_Comments__c from Case where Id IN :ParentIds]){
Double UserSum = CaseMap.get (cs.Id);
cs.Number_of_Comments__c=UserSum;
CasesToUpdate.add(cs);
}
update CasesToUpdate;
}
- klocwork
- December 08, 2011
- Like
- 0
- Continue reading or reply
Can't insert or upsert Contracts using the dataloader
Hello,
I'm working on migrating data out of our legacy systems and am having a heck of a time as I can't seem to get the dataloader to bring in Contract records. Everytime it runs the file it says it completes, with 0 errors and 0 successes. The file I am using has 1928 records, and the data loader sees the records as it reports that that will be the total as soon as I point @ the csv
The file structure I am using includes:
InTouch_Installation_ID__c
InTouch_Account_ID__c
AccountID
DivisionID__c
Status
CustomerSignedDate
ActivatedDate
EndDate
CustomerSigned
ContractTerm
Can anybody shed light on WHY the data loader isn't reporting errors, and is not importing any records?
Thanks!
- klocwork
- September 12, 2011
- Like
- 0
- Continue reading or reply
Customer portal users see all cases
Greetings!
I'm setting up a Customer Community for my clients to access my instance of salesforce to open and track their own Cases. I went through he setup steps outlined to enable users and was in the process of testing the visibility of community users to their cases (where they are the contact on the case) and discovered that while logged in as a community user I can see all cases, and can open the records.
Is there a permission setting for Customer Community I am missing?
- klocwork
- September 25, 2013
- Like
- 0
- Continue reading or reply
Trigger Help: Too many code statements
Greetings!
I've been backwards and forwards through the forums here looking at the examples of solutions to "System.LimitException: Too many code statements: 200001" errors and have made a number of the suggested modifications (that I can figure out) to my code below. I am easily able to update a handful of records, but as soon as I try to push 50 or more through the trigger I get the error.
I am swimming in the deep end and beyond my current comfort. I would sincerely appreciate some input and guidance on how I can best address the issue I'm seeing!
The intent of this code is to align the OwnerId of all related Leads and Contacts when an Account either has a new Owner assigned, or when a check box is selected. Stipulations - the Account and the Lead records must have North American Country values.
Thanks
trigger Account_ChangeOwner on Account (before update) { //This trigger updates Lead and Contact Owners based on either a new Account Owner or a selected check box integer counter=0; Set<Id> AccountIds = new Set<Id>(); For (Account Obj : trigger.new){ //Only applies to North American Accounts if (Obj.BillingCountry!=null && ( Obj.BillingCountry=='CA' || Obj.BillingCountry=='US' || Obj.BillingCountry=='Canada' || Obj.BillingCountry=='United States') ) { if (Obj.OwnerId!=trigger.old[counter].OwnerId) { AccountIds.add(Obj.Id); } else if (Obj.Reset_Contact_Owners__c==true) { AccountIds.add(Obj.Id); } } counter++; }//end of loop 1 //Gather all relevant Leads and Conacts and add them to Lists list<Lead> Lead_list = [Select l.Id, l.Account_Record__c, l.OwnerId From Lead l where l.IsDeleted=false and l.IsConverted=false //Only applies to North American Leads and (l.Country!=null and ( l.Country='CA' or l.Country='US' or l.Country='Canada' or l.Country='United States')) and Account_Record__c IN :AccountIds]; list<Contact> Contact_list = [Select c.Id, c.AccountId, c.OwnerId From Contact c where c.IsDeleted=false and AccountId IN :AccountIds]; //Make the changes counter=0; For (Account Obj : trigger.new){ if (Obj.OwnerId!=trigger.old[counter].OwnerId || Obj.Reset_Contact_Owners__c==true){ //Review the Leads and Contacts for the Acounts and change the Owner; For (Lead MyLead : Lead_list){ if (MyLead.Account_Record__c==Obj.Id){ if (Obj.Named_Account__c==true){ MyLead.OwnerId=Obj.OwnerId; } } } { For (Contact MyContact : Contact_list){ if (MyContact.AccountId==Obj.Id){ MyContact.OwnerId=Obj.OwnerId; } } } } //Clear the Reset Contact Owners field if (Obj.Reset_Contact_Owners__c==true){ Obj.Reset_Contact_Owners__c=false; } counter++; }//end of loop 2 //Process Leads Lead[] LeadsToUpdate=new Lead[]{}; For (Lead MyLead : Lead_list){ LeadsToUpdate.add(MyLead); if (LeadsToUpdate.size()==5000){ update LeadsToUpdate; LeadsToUpdate.clear(); } } if (LeadsToUpdate.size()>0){ update LeadsToUpdate; } //Process Contacts Contact[] ContactsToUpdate=new Contact[]{}; For (Contact MyContact : Contact_list){ ContactsToUpdate.add(MyContact); if (ContactsToUpdate.size()==5000){ update ContactsToUpdate; ContactsToUpdate.clear(); } } if (ContactsToUpdate.size()>0){ update ContactsToUpdate; } }//end of trigger
- klocwork
- June 03, 2013
- Like
- 0
- Continue reading or reply
Unexpected Identifier error in JavaScript button
I am spinning my wheels on this and completely stumped. When I try this code I get "A problem with the OnClick JavaScript for this button or link was encountered: Unexpected identifier".
What I am trying to do is update a custom object (Sales_Cycle__c) and the Lead record that it relates to (Sales_Cycle__c.Lead__c).
Any help would be greatly appreciated!
Thank you.
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")} var CycleUpdate = new sforce.SObject("Sales_Cycle__c"); var l = SELECT Id, Status FROM Lead where Id =\'"+ CycleUpdate.Lead__c + "\' limit 1"; CycleUpdate.Id='{!Sales_Cycle__c.Id }'; CycleUpdate.Sales_Cycle_Status__c = 'No Further Interest'; CycleUpdate.Date_Sales_Cycle_Ended__c = new Date(); l.Status = 'No Further Interest'; update CycleUpdate; update l; window.location.reload();
- klocwork
- May 13, 2013
- Like
- 0
- Continue reading or reply
Checking for null value is not returning results
Spinning my wheels on this. I'm not an APEX coder but this problem is within my skill set.
I am trying to check to see if "Account_Record__c" on "Lead" is null - and then insert a record if it is. No errors when I save the code, but when I test none of the records are behaving as expected! In my test records there are no values in "Account_Record__c" yet the related object record is not created. If I remove the "&& newLead.Account_Record__c==null" element then the related record is created.
What am I missing?
trigger createSalesAssignment on Lead (after update) { List<Sales_Assignment__c> sa = new List<Sales_Assignment__c>(); for (Lead newLead: Trigger.New) if (newLead.Status == 'Sales Ready' && newLead.Account_Record__c==null){ sa.add (new Sales_Assignment__c( Lead__c = newLead.Id)); } insert sa; }
- klocwork
- August 10, 2012
- Like
- 0
- Continue reading or reply