+ Start a Discussion
Gelu G.Gelu G. 

Apex class for a trigger failing

Hi,
I have created a trigger that will be used by the marketing cloud connector for trigger sends.  The trigger is as follows:
trigger Trig_Account on Account (after insert, after update) {
    et4ae5.triggerUtility.automate('Account');
}
The test class for this trigger is:
 
@isTest
private class Trig_AccountTest {
static testMethod void myUnitTest() {
Account testAccount = new Account(RecordTypeId = '012c00000009EzV', LastName = 'Test Contact', PersonEmail = 'de123@yahoo.com');
insert testAccount;
testAccount = [select Id, LastName from Account where id = :testAccount.Id];
System.assertEquals(testAccount.LastName, 'Test Contact');
    }
}
When executing the test, I keep getting the error below.  It's a simple test and it's not obvious to me what could be missing.  
 
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 11, column 1
Trigger.Trig_Account: line 2, column 1: []



 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same issue
1) https://salesforce.stackexchange.com/questions/172024/marketing-cloud-import-user-does-not-have-access-to-salesforce-objects-or-re

Each Marketing Cloud User will need to be configured as an integrated user, which links their Sales Cloud account to the Marketing Cloud Account

Let us know if this will help you

 
sukanya banekarsukanya banekar
Hi Fitsum,
There is a wrong parameter in your code
et4ae5.triggerUtility.automate('Account');

instead of ('Account') you should send account record i.e. (trigger.new)

Let me know if this helps you to solve your problem.

Thanks,
Sukanya Banekar   
John BlaserJohn Blaser
Fitsum - Were you able to resolve this issue? I'm having the same problem.
Fitsum Worku 5Fitsum Worku 5
Hi John,
I wasn't able to resolve this.  There was no need for us to do trigger sends from Salesforce so I didn't pursue it that much.