You need to sign in to do that
Don't have an account?
Gelu G.
Apex Test Class failing for triggered send
Hello all,
Our Sales Cloud and Marketing Cloud are connected via the Marketing Cloud Connector. I am trying to use the triggered send feature of Sales Cloud and send a Marketing Cloud email when a person account is created in the Sales Cloud.
I have the following trigger and test class set up on my Sandbox environment.
Our Sales Cloud and Marketing Cloud are connected via the Marketing Cloud Connector. I am trying to use the triggered send feature of Sales Cloud and send a Marketing Cloud email when a person account is created in the Sales Cloud.
I have the following trigger and test class set up on my Sandbox environment.
trigger Trig_Account on Account (after insert, after update) { if (!Test.isRunningTest()){ et4ae5.triggerUtility.automate('Account'); } } @isTest private class Trig_AccountTest { static testMethod void myUnitTest() { Account testAccount = new Account(LastName = 'Test Account', PersonEmail= 'testclass@test.com'); insert testAccount; testAccount = [select Id, LastName from Account where id = :testAccount.Id]; System.assertEquals(testAccount.LastName, 'Test Account'); } }The test class executes without any problems but the code coverage on the trigger remains at 50%(1/2). I won't be able to deploy this to production because it needs to be at 75% at least. I can't see what I am doing wrong here so any help will be apprecaited.
Solved this by writing the trigger and test class as follows:
All Answers
Remove the below line and check once:
if (!Test.isRunningTest()){ }
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions and training videos :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Thanks,
V Varaprasad
Email: varaprasad4sfdc@gmail.com
Mobile No : +91 9393934143
If I remove that, I get the error below. We have person account enabled. Does it mean support have to enable it for triggered send?
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trig_Account: execution of AfterInsert
caused by: et4ae5.MCBaseException.InvalidParameterException: Whoops! Marketing Cloud Connect does not have access to the selected object. Contact your administrator to enable objects for Marketing Cloud Connect triggered sends.
Class.et4ae5.triggerUtility.automate: line 30, column 1
Trigger.Trig_Account: line 2, column 1: []
https://salesforce.stackexchange.com/questions/181699/marketing-cloud-triggered-send
https://salesforce.stackexchange.com/questions/210508/unable-to-deploy-trigger-for-triggered-sends-to-activate
Solved this by writing the trigger and test class as follows: