-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
5Questions
-
3Replies
No coverage on test class
Trigger:
trigger PartnerLeadAssignment on Lead (before insert) { List<Lead> leadList = new List<Lead>(); for(Lead l : trigger.new){ leadList.add(l); if(l.Company == null){ l.Company = l.FirstName + ' ' + l.LastName; if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002SuHKtQAN'){ l.OwnerId = '0050H0000090O6HQAU'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Vv9gqQAB'){ l.OwnerId = '0050H00000BwRULQA3'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002PZz8zQAD'){ l.OwnerId = '0050H000009LmB3QAK'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001siaFLAAY'){ l.OwnerId = '005i0000007xZy2AAE'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001R92ADAAZ'){ l.OwnerId = '005i0000004jpjbAAA'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002LTwKnQAL'){ l.OwnerId = '0050H0000090Mz0QAE'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000Rr2XRAAZ'){ l.OwnerId = '005i0000006ozUbAAI'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001lbahkAAA'){ l.OwnerId = '005i0000007CtxhAAC'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002WhyBJQAZ'){ l.OwnerId = '0050H00000BNF5XQAX'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Gbu8mQAB'){ l.OwnerId = '0050H00000A9mp3QAB'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QeX7JQAV'){ l.OwnerId = '0050H0000090IR1QAM'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Wk18hQAB'){ l.OwnerId = '0050H00000BwWykQAF'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QeXBVQA3'){ l.OwnerId = '0050H0000090HG2QAM'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002JJNojQAH'){ l.OwnerId = '0050H000009LjrVQAS'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002WhxgEQAR'){ l.OwnerId = '0050H00000BpsLdQAJ'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001p21CnAAI'){ l.OwnerId = '005i0000007E1poAAC'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000N2CBbAAN'){ l.OwnerId = '005i00000058XOlAAM'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000N2CJ8AAN'){ l.OwnerId = '005i0000007CVm0AAG'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QectbQAB'){ l.OwnerId = '0050H0000090OXcQAM'; } } }
Test Class:
@isTest public class PartnerLeadAssignmentTest { static testMethod void insertLead(){ List<Lead> leadList = new List<Lead>(); Lead l = New Lead(Company = '', FirstName = 'First', LastName = 'Last', leadSource = 'Website', lead_SubType__c = 'Contact Requested'); leadList.add(l); if(l.Referring_Brand_Id__c == '0010H00002SuHKtQAN'){ insert l; l=[Select Company, FirstName, LastName, Referring_Brand_Id__c, LeadSource, OwnerId, RecordTypeId FROM Lead Where Id =:l.Id]; System.assertEquals('0050H0000090O6HQAU', l.OwnerId); } if(l.Referring_Brand_Id__c == '0010H00002Vv9gqQAB'){ insert l; l=[Select Company, FirstName, LastName, Referring_Brand_Id__c, LeadSource, OwnerId, RecordTypeId FROM Lead Where Id =:l.Id]; System.assertEquals('0050H00000BwRULQA3', l.OwnerId); } } }
-
- Travis Dvorak
- July 17, 2019
- Like
- 0
- Continue reading or reply
InboundEmailHandler toAddress list
I'm creating email to custom object records via the InboundEmailHandler. (sorry if my verbage is wrong on that).
What I have working is the email to custom object, as well as the attachments to the record, but having issues creating a new EmailMessage that is associated with the custom object record.
I have all the fields figured out minus the toAddress since it's inserting via a list to string. I'm not sure how to convert that to a list. Any help would be appreciated. Here is the code:
global class CreateTradeSupport implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env){ Messaging.InboundEmailResult result = new Messaging.InboundEmailResult(); String myPlainText= ''; Contact c; myPlainText = email.plainTextBody; try{ if([SELECT count() from Contact where email =:email.fromAddress] == 0){ c = new Contact(); c.LastName = email.fromName; c.Email = email.fromAddress; insert c; } else{ c = [SELECT Id from Contact Where email =:email.fromAddress LIMIT 1]; } Trade_Support__c ts = new Trade_Support__c(); ts.Description__c = myPlainText; ts.Status__c = 'New'; ts.Subject__c = email.subject; ts.web_email__c = email.fromAddress; ts.contact__c = c.Id; insert ts; EmailMessage mail = new EmailMessage(); mail.Subject = email.subject; mail.FromAddress = email.fromAddress; mail.HtmlBody = email.htmlBody; mail.TextBody = myPlainText; mail.FromName = email.fromName; mail.RelatedToId = ts.Id; //This is where I'm having issues mail.toAddress = email.toAddresses; mail.CcAddress = email.ccAddresses; mail.Status = 'Read'; insert mail; // Save attachments, if any List<Attachment> attachments = new List<Attachment>(); if(email.textAttachments != null) { for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) { Attachment attachment = new Attachment(); attachment.Name = tAttachment.fileName; attachment.Body = Blob.valueOf(tAttachment.body); attachment.ParentId = ts.Id; attachments.add(attachment); } } if(email.binaryAttachments != null) { for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) { Attachment attachment = new Attachment(); attachment.Name = bAttachment.fileName; attachment.Body = bAttachment.body; attachment.ParentId = ts.Id; attachments.add(attachment); } } if(attachments.size() > 0) { insert attachments; } } catch (QueryException e) { System.debug('Query Issue: ' + e); } result.success = true; return result; } }
-
- Travis Dvorak
- May 01, 2019
- Like
- 0
- Continue reading or reply
Bypass trigger while using data loader?
if(c.skip_validation__c = true){
return;
}
so when the case update is loaded, I add the value of "skip_validation__c" to true, which will bypass it. At the end of the validation trigger (or a separate one), I would like to update any case that has "case_validation__c" as "true" and update it false, so it doesn't bypass the validation trigger going forward. How would I accomplish this? Tried via process builder, but doesn't work since it would be saved not meeting the criteria.
-
- Travis Dvorak
- December 07, 2018
- Like
- 0
- Continue reading or reply
Proper case formula
IF (
FIND(" ", [Lead].State ,1)=0,
UPPER(LEFT([Lead].State ,1))&LOWER(MID([Lead].State,2,LEN([Lead].State)-1)),
IF(
FIND(" ",MID([Lead].State ,FIND(" ",[Lead].State ,1)+1,LEN([Lead].State)-FIND(" ",[Lead].State,1)))=0,
UPPER(LEFT([Lead].State ,1))&LOWER(MID([Lead].State ,2,FIND(" ",[Lead].State ,1)-1))&UPPER(MID([Lead].State ,FIND(" ",[Lead].State ,1)+1,1))&LOWER(MID([Lead].State ,FIND(" ",[Lead].State ,1)+2,LEN([Lead].State)-1)),
UPPER(LEFT([Lead].State ,1))&LOWER(MID([Lead].State ,2,FIND(" ",[Lead].State ,1)-1))&UPPER(MID([Lead].State ,FIND(" ",[Lead].State ,1)+1,1))&LOWER(MID([Lead].State ,FIND(" ",[Lead].State ,1)+2,FIND(" ",MID([Lead].State ,FIND(" ",[Lead].State ,1)+1,LEN([Lead].State )-FIND(" ",[Lead].State ,1)))-1))&
UPPER(MID([Lead].State ,FIND(" ",MID([Lead].State ,FIND(" ",[Lead].State ,1)+1,LEN([Lead].State)-FIND(" ",[Lead].State ,1)))+FIND(" ",[Lead].State ,1)+1,1))&LOWER(MID([Lead].State ,FIND(" ",MID([Lead].State ,FIND(" ",[Lead].State ,1)+1,LEN([Lead].State )-FIND(" ",[Lead].State ,1)))+FIND(" ",[Lead].State ,1)+2,LEN([Lead].State)-1))
)
)
-
- Travis Dvorak
- October 09, 2018
- Like
- 0
- Continue reading or reply
Relate AccountTeam object to User object using PB and Flow?
Hello. Sorry in advance as I'm a newbie for deveopment. Background to my scenario before I ask the question. We use "Roles" as a way to differentiate the offices that are using our org.
We have a private sharing model for Accounts, Cases, Contacts and Leads. Whenever a new office joins, or when a new employee for an existing office starts, we need to udpate the Account Team for each user as every user within a specified role should have edit access to Accounts, Contacts, Leads and Cases.
I have created a flow that, when a user is created, it will automatically add that user to other users in that roles Account Team, and add the existing users to the newly created users Account Team.
Works perfect, except a HUGE flaw - it only works for accounts that are created after the created date of the user.
So it doesn't check the box of "Update Account teams with these members" like you can do when you manually add users:
I tried to experiement with making my flow gather existing accounts and add that user to that Account Team, but I'm getting an error of:
Error Occurred: This error occurred when the flow tried to create records: MIXED_DML_OPERATION: DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): AccountShare, original object: User. You can look up ExceptionCode values in the SOAP API Developer Guide.---
I understand why this is happening - the way this is triggered is by Process Builder on the User object. The user object can't reference Accounts, which means I'm going to have to build a trigger (I think?)
I'm by no means asking for anyone in the community to build this for me, but at least let me know if what I want to accomplish is possible?
Or, if a trigger isn't necessary, is it possible to somehow tell my flow to check that stupid box that will solve all my problems?
-
- Travis Dvorak
- September 28, 2018
- Like
- 0
- Continue reading or reply
No coverage on test class
Trigger:
trigger PartnerLeadAssignment on Lead (before insert) { List<Lead> leadList = new List<Lead>(); for(Lead l : trigger.new){ leadList.add(l); if(l.Company == null){ l.Company = l.FirstName + ' ' + l.LastName; if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002SuHKtQAN'){ l.OwnerId = '0050H0000090O6HQAU'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Vv9gqQAB'){ l.OwnerId = '0050H00000BwRULQA3'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002PZz8zQAD'){ l.OwnerId = '0050H000009LmB3QAK'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001siaFLAAY'){ l.OwnerId = '005i0000007xZy2AAE'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001R92ADAAZ'){ l.OwnerId = '005i0000004jpjbAAA'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002LTwKnQAL'){ l.OwnerId = '0050H0000090Mz0QAE'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000Rr2XRAAZ'){ l.OwnerId = '005i0000006ozUbAAI'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001lbahkAAA'){ l.OwnerId = '005i0000007CtxhAAC'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002WhyBJQAZ'){ l.OwnerId = '0050H00000BNF5XQAX'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Gbu8mQAB'){ l.OwnerId = '0050H00000A9mp3QAB'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QeX7JQAV'){ l.OwnerId = '0050H0000090IR1QAM'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Wk18hQAB'){ l.OwnerId = '0050H00000BwWykQAF'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QeXBVQA3'){ l.OwnerId = '0050H0000090HG2QAM'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002JJNojQAH'){ l.OwnerId = '0050H000009LjrVQAS'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002WhxgEQAR'){ l.OwnerId = '0050H00000BpsLdQAJ'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001p21CnAAI'){ l.OwnerId = '005i0000007E1poAAC'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000N2CBbAAN'){ l.OwnerId = '005i00000058XOlAAM'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000N2CJ8AAN'){ l.OwnerId = '005i0000007CVm0AAG'; } if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QectbQAB'){ l.OwnerId = '0050H0000090OXcQAM'; } } }
Test Class:
@isTest public class PartnerLeadAssignmentTest { static testMethod void insertLead(){ List<Lead> leadList = new List<Lead>(); Lead l = New Lead(Company = '', FirstName = 'First', LastName = 'Last', leadSource = 'Website', lead_SubType__c = 'Contact Requested'); leadList.add(l); if(l.Referring_Brand_Id__c == '0010H00002SuHKtQAN'){ insert l; l=[Select Company, FirstName, LastName, Referring_Brand_Id__c, LeadSource, OwnerId, RecordTypeId FROM Lead Where Id =:l.Id]; System.assertEquals('0050H0000090O6HQAU', l.OwnerId); } if(l.Referring_Brand_Id__c == '0010H00002Vv9gqQAB'){ insert l; l=[Select Company, FirstName, LastName, Referring_Brand_Id__c, LeadSource, OwnerId, RecordTypeId FROM Lead Where Id =:l.Id]; System.assertEquals('0050H00000BwRULQA3', l.OwnerId); } } }
- Travis Dvorak
- July 17, 2019
- Like
- 0
- Continue reading or reply
Has anyone ever created a formula to proper case fields?
Has anyone ever created a formula to proper case fields?
Thank you,
Steve
- RelaxItsJustCode
- October 18, 2012
- Like
- 0
- Continue reading or reply