• Sombir Sheoran
  • NEWBIE
  • 20 Points
  • Member since 2017
  • Technical Lead
  • DXC Technologies


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hello Everyone,

I have created 1 trigger on Account which opens a case as soon as we create the account.
So, as soon as I have written both the codes and now testing with testClass, it is not creating a new Account record in my salesforce org. and hence also not opening any case.

Is there anything I am missing here. Support is really appreciated.

1. Trigger on Account to open a case 
trigger CreateTShirtCaseonAccount on Account (after insert) {
    for(Account ListofAllAccount: Trigger.New)
    {
        Case newTshirtCase = new Case();
        newTshirtCase.Subject = 'Congratulations, your account is opened, with free T-Shirt from us';
        newTshirtCase.Priority = 'High';
        newTshirtCase.AccountId = ListofAllAccount.id;
        insert newTshirtCase;
    }
}


2. Test Class to test the trigger

@isTest
public class TestAccountTrigger {
    static testMethod void accountCreator()
    {
        Account newAccount = new Account();
        newAccount.Name = 'Account Created with TestClass : TestAccountTrigger';
        insert newAccount;
    }
}



Regards,
Sombir Sheoran
Hello Everyone,

I have created 1 trigger on Account which opens a case as soon as we create the account.
So, as soon as I have written both the codes and now testing with testClass, it is not creating a new Account record in my salesforce org. and hence also not opening any case.

Is there anything I am missing here. Support is really appreciated.

1. Trigger on Account to open a case 
trigger CreateTShirtCaseonAccount on Account (after insert) {
    for(Account ListofAllAccount: Trigger.New)
    {
        Case newTshirtCase = new Case();
        newTshirtCase.Subject = 'Congratulations, your account is opened, with free T-Shirt from us';
        newTshirtCase.Priority = 'High';
        newTshirtCase.AccountId = ListofAllAccount.id;
        insert newTshirtCase;
    }
}


2. Test Class to test the trigger

@isTest
public class TestAccountTrigger {
    static testMethod void accountCreator()
    {
        Account newAccount = new Account();
        newAccount.Name = 'Account Created with TestClass : TestAccountTrigger';
        insert newAccount;
    }
}



Regards,
Sombir Sheoran