function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
roysmith601.3493067652527424E1roysmith601.3493067652527424E1 

Trigger error on activity object update the opportunity object

I have to add record type to my record. for example, if user click on event and we have 4 record type but we want to this functionlaity to work for only one event record.

 

I enter the if statement but i am getting the following error:

Error: Compile Error: Variable does not exist: t.Subject at line 4 column 5

 

my trigger is as follow:

 

trigger eventafter on Event (after insert,after update) {
List<Opportunity> opps = new List<Opportunity>{};

if (t.Subject != null && t.WhatId.getSObjectType() == Opportunity.sObjectType && t.RecordType.Name = 'Opportunity Event')


if(trigger.isInsert)
{
for (Event t : trigger.new)
{
if (t.Subject != null && t.WhatId.getSObjectType() == Opportunity.sObjectType)
{
opps.add(new Opportunity(Id = t.WhatId, StageName = t.Subject));
}
}
}
else
{
for(Event t : trigger.new)
{
if(t.Subject != null
&& t.WhatId.getSObjectType() == Opportunity.sObjectType
&& t.Subject != trigger.oldMap.get(t.Id).Subject)
{
opps.add(new Opportunity(Id = t.WhatId, StageName = t.Subject));
}

}
}

if(opps != null && !opps.isEmpty()){
Database.update(opps);
}
}

 

 Please help that why i am getting this error and how can i reslove this.Also,If i have to use this for Bulk record then how can i use that in my current trigger.

i m new to salesforce so please help me

thanks