I am trying to default the Account Name in a case to 'abc corp' but while executing the code, it gives the error
Attempt to de-reference a null object. its happening at line 10 which c.account.name = defaultAcc.Id
.
The code
trigger DefaultAccName on Case(after insert, after update) {
Account defaultAcc = [
SELECT Id
FROM Account
WHERE Name ='abc corp'];
for (Case c: trigger.New) {
if (defaultAcc.Id != null)
{
if(c.Type=='Internal')
{
c.account.name = defaultAcc.Id;
}
}
}
}
Any help in resolving this is appreciated.
Deepak