Write a trigger with its test class that does the following when an Account is created: - Create a new case - Assign the owner to Account owner - Subject : Dedupe this Account - Associate with the Account

 Write a trigger with its test class that does the following when an Account is created:

- Create a new case
- Assign the owner to Account owner
- Subject : Dedupe this Account
- Associate with the Account
....Trigger....
Trigger
trigger DedupeReminder on Account (after Insert) {
    for (Account acc: Trigger.New){
        Case c      = New Case();
        c.subject   = 'Dedupe this Account';
        c.OwnerId   = '0055g000009H34XAAS';
        c.AccountId = acc.Id;
        insert c;
    }
}
Find the owner id using this query - Select Ownerid, name from Account                                         
....Test Class....
@istest
public class DedupeTestClass {
    @istest
    static void TestAccountTri(){
        Account Acc = new Account();
        Acc.Name = 'Test';
        insert Acc;
        Case c  = New Case();
        c.subject = 'Dedupe this Account';
        c.OwnerId = '0055g000009H34XAAS';
        c.AccountId = acc.Id;
        insert c;
       //DedupeTestClass.TestAccountTri();
    }
}

Comments

Popular posts from this blog

Write a trigger and it's Test class on Account when Account is update check all opportunity inside the account.