• KatherineC
  • NEWBIE
  • 125 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 45
    Replies
Hi All,
We created a trigger on FeedComment - a new record under ChatterPost will be created automatically when a comment contains keyword "legal". The test class has error that missing FeedItemId, we're not sure how to get it fix, please help.

Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [FeedItemId]: [FeedItemId]
Stack Trace Class.CommentKeywordlegalTest.insertNewChatterPostTest: line 13, column 1

@isTest
public class CommentKeywordlegalTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem f = new FeedItem();
        f.ParentId = UserInfo.getUserId();
        f.body = 'test';
        insert f;
        FeedComment fc = new FeedComment();
        fc.CommentBody = 'legal test';
        insert fc;
        Test.StopTest();
        System.assertEquals ('legal test', fc.commentbody);
    }
}

TRIGGER:
Trigger CommentKeywordLegal on FeedComment (after insert) {
    List<FeedComment> FeedComments = new List<FeedComment>();
   for (FeedComment f : Trigger.new) {
           if (f.commentbody!=null &&   f.commentbody.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.commentbody;
                     
              insert C;
        }
    }
   }

Hi All,
We created a trigger for Chatter. When a post contains keyword ”legal', a new record under ChatterPost will be generated. We also created Test class but got error, please help, thank you so much.

Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ParentId]: [ParentId]
Stack Trace Class.ChatterPostTest.insertNewChatterPostTest: line 9, column 1


@isTest
public class ChatterPostTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem f = new FeedItem();
        f.Body = 'legal test';
        insert f;
        Test.StopTest();
        System.assertEquals ('legal test', f.body);
    }
}

TRIGGER:
Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body!=null &&   f.body.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                   
              insert C;
        }
    }
   }
Hi All,
We created a trigger for Chatter. When a post contains keyword ”legal', a new record under ChatterPost will be generated. We also created Test class but got error, please help, thank you so much.

Compile Error: Illegal assignment from Schema.SObjectField to Id at line 8 column 9

@isTest
public class ChatterPostTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem post = new FeedItem();
        post.ParentId = ChatterPost__c.Id;
        post.Body = 'legal test';
        insert post;
        Test.StopTest();
        System.assertEquals ('legal test', post.body);
    }
}

TRIGGER:
Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body!=null &&   f.body.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                     
              insert C;
        }
    }
   }
Hi All,
We created a trigger on Chatter. If a post mentions “legal" keyword, a new record under ChatterPost object is created automatically. But it's not working, no new record is created, please help.

Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body == '!legal' ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                     
              insert C;
        }
    }
   }
Hi All,

We want to send out email alert when certain key words (like legal, tax) are mentioned in Chatter post. We notice Feed Item Trigger, can we use that to achieve this and how? Based on our research it seems Feed Item Trigger is for insert/delete post, can it trigger to send out email alert or create a new record? Ideally it can trigger to send out email alert, if not we're thinking to create a process like this, when someone mentions "legal" in the post, trigger will fire to create a record under a custom object we build and subsequently send out email alert by workflow rule. Any suggestions? Thanks.
Hi All,
I created a trigger, so that when a new event is created in Public Calendar a new CalendarEV record will be created automatically. I got error message after running test class that missing required fields, so no code coverage at all. I noticed that both Start and End fields in Event object are required Date/Time fields, so I wonder how to create Date/Time in test class for these two fields so that an event can be created and fire the trigger. Please help.

Error message: System.DmLException: insert failed. First exception on row 0; First error, Required field missing
Stack Trace: Class.CalendarEVTest.insertNewCalendarEV: Line11, colum 1

trigger CalendarEV on Event (after insert) {
List<Event> Events = new List<Event>();
   for (Event e : Trigger.new) {
           if (e.Subject != null ) {
               CalendarEV__c C = new CalendarEV__c();
               c.Name = e.Subject;
               c.Start__c = e.StartDateTime;
               c.End__c = e.EndDateTime;
               c.Location__c = e.Location;
               c.Description__c = e.Description;
                    
              insert C;
        }
    }
   }


@isTest
public class CalendarEVTest
{
    static testMethod void insertNewCalendarEV()
    {
        Test.StartTest();
        Event e = new Event();
        e.Subject = 'Test Event';
        e.Location = 'Test Location';
        e.Description = 'Test Description'; 
        insert e;
        Test.StopTest();
        System.assertEquals ('Test Event', e.Subject);
    }
}
Hi All,
I created a trigger so that when a new event is created in Public Calendar a new record under custom object CalendarEV will be created automatically, I also created the test class, it runs successfully but no code coverage, please help.

trigger CalendarEV on Event (after insert) {
    List<Event> Events = new List<Event>();
   for (Event e : Trigger.new) {
           if (e.Subject != null ) {
               CalendarEV__c C = new CalendarEV__c();
               c.Name = e.Subject;
               c.Start__c = e.StartDateTime;
               c.End__c = e.EndDateTime;
               c.Location__c = e.Location;
               c.Description__c = e.Description;
                
              insert C;
        }
    }
   }


@isTest
public class CalendarEVTest
{
    static testMethod void insertNewCalendarEV()
    {
        Test.StartTest();
        Event event = new Event();
        event.Subject = 'Test Event';
        event.Location = 'Test Location';
        event.Description = 'Test Description';      
        Test.StopTest();
    }
}
Hi All,
We created a custom Object CalendarEV, we want a new record for CalendarEV is created automatically  when a new event is created in Public Calendar. We created below trigger but got error message, please help.

Error: Compile Error: Expression cannot be assigned at line -1 column -1

trigger CalendarEV on Event (after insert) {
    List<Event> Events = new List<Event>();
   for (Event e : Trigger.new) {
           if (Event.Subject != null ) {
               CalendarEV__c C = new CalendarEV__c();
               CalendarEV__c.Name = Event.Subject; 
               CalendarEV__c.Location__c = Event.Location;
               CalendarEV__c.Description__c = Event.Description;
                       
              insert C;
        }
    }
   }
Hi All,
I have this trigger once checkbox MSep30 is checked, a new Pint will be generated, Account will be the same as previous Pint, but we want to pull Account Owner from Account Object in case there's change of Account owner. But error message says variable "Account.Owner.Firstname & Account.Owner.Lastname" don't exist, please help.

trigger MSep30 on Pint__c (after update) {
    List<Pint__c> pints = new List<Pint__c>();
   for (Pint__c p : Trigger.new) {
           if (p.MSep30__c == true ) {
               Pint__c newPint = new Pint__c();
               newPint.Account__c = p.Account__c;
               newPint.Pint_Owner__c = Account.Owner.Firstname & Account.Owner.Lastname
               newPint.Payroll_Date__c = p.Payroll_Date__c + 30;
               newPint.Schedule_Start_Date_5_Biz_Days_Prior_PR__c = p.Payroll_Date__c + 23;
               pints.add(newPint);
        }
    }
   if(pints.size() > 0) insert pints;
}
Hi All,

We want a new Pint is self-generated once checkbox Oct31 is checked (true), account and pint owner have to be the same, new pint's payroll date wil be 16 days more and new pint's schedule start date will be 9 days more of old pint's payroll date. I got this trigger and test class, the coverage is 70%, did not pass, please help me write the test class to increase coverage. Many thanks.

trigger Oct31Pint on Pint__c (after update) {
    List<Pint__c> pints = new List<Pint__c>();
   for (Pint__c p : Trigger.new) {
           if (p.Oct31__c == true ) {
               Pint__c newPint = new Pint__c();
               newPint.Account__c = p.Account__c;
               newPint.Pint_Owner__c = p.Pint_Owner__c;
               newPint.Payroll_Date__c = p.Payroll_Date__c + 16;
               newPint.Schedule_Start_Date_5_Biz_Days_Prior_PR__c = p.Payroll_Date__c + 9;
               pints.add(newPint);
        }
    }
   if(pints.size() > 0) insert pints;
}


TEST:

@isTest
public class TestOct31Pint
{
    static testMethod void insertNewPint()
    {
        Account account = new Account();
        account.Name = 'Test Account';
        insert account;
        Pint__c PintToCreate = new Pint__c();
        PintToCreate.Account__c = account.Id;
        insert PintToCreate;
        Test.StartTest();
        PintToCreate.Oct31__c = true;
        update PintToCreate;
        Test.StopTest();
    }
}
Hi,

I researched up and down to come up with below visualforce code for a calendar, the calendar shows but can not create events, what am I missing here?

<apex:page controller="CalendarExample_Controller" action="{!pageLoad}">

    <link href="{!$Resource.fullCalendarCSS}" rel="stylesheet" />

    <link href="{!$Resource.fullCalendarPrintCSS}" rel="stylesheet" media="print" />

    <apex:includeScript value="{!URLFOR($Resource.FullCalendar, '/fullcalendar-2.0.3/lib/moment.min.js')}"  />

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

    <script src="{!$Resource.fullCalendarMinJS}"></script>

   

    <script>

        //We need to wrap everything in a doc.ready function so that the code fires after the DOM is loaded

        $(document).ready(function() {  

            //Call the fullCallendar method. You can replace the '#calendar' with the ID of the dom element where you want the calendar to go.

            $('#calendar').fullCalendar({

                header: {

                    left: 'prev,next today',

                    center: 'title',

                    right: 'month,agendaWeek,agendaDay'

                },
             
              editable: true, 
                   
                eventRender: function(event, element) {
        element.qtip({
            content: {
                title: {
                    text: event.title
                },
                text: '<span class="title">Date: </span>' + ($.fullCalendar.formatDate(event.start, 'MM/dd/yy')) + '<br><span class="title">Time: </span>' + ($.fullCalendar.formatDate(event.start, 'hh:mmtt')) + '<span class="title"> to </span>' + ($.fullCalendar.formatDate(event.end, 'hh:mmtt')) + '<br><span class="title">Event: </span>' + event.Name + '<br><span class="title">Driver: </span>' + event.driver + '<br><span class="title">Location: </span>' + event.location + '<br><span class="title">Commidity: </span>' + event.commidity + '<br><span class="title">Description: </span>' + event.description
            },
            show: {
                solo: true
            },
            //hide: { when: 'inactive', delay: 3000 },
            position: {
                corner: {
                    target: 'topLeft',
                    tooltip: 'bottomRight'
                }
            },
            style: {
                width: 200,
                padding: 5,
                color: 'black',
                textAlign: 'left',
                border: {
                    width: 1,
                    radius: 3
                },

                classes: {
                    tooltip: 'ui-widget',
                    tip: 'ui-widget',
                    title: 'ui-widget-header',
                    content: 'ui-widget-content'
                }
            }
        });

    },

    dayClick: function(date, allDay, jsEvent, view) {
        var $dialogContent = $("#event_edit_container");

        y = date.getFullYear();
        m = date.getMonth();
        d = date.getDate();

        h1 = date.getHours();
        m1 = date.getMinutes();

        h2 = h1 + 1;
        m2 = m1;

        calEvent = {
            title: 'New Calendar Event',
            editable: true,
            start: new Date(y, m, d, h1, m1),
            end: new Date(y, m, d, h2, m2),
            allDay: false
        }
            }
          
            });

           

        });

   

    </script>

   

    <!--some styling. Modify this to fit your needs-->

    <style>

        #cal-options {float:left;}

        #cal-legend { float:right;}

        #cal-legend ul {margin:0;padding:0;list-style:none;}

        #cal-legend ul li {margin:0;padding:5px;float:left;}

        #cal-legend ul li span {display:block; height:16px; width:16px; margin-right:4px; float:left; border-radius:4px;}

        #calendar {margin-top:20px;}

        #calendar a:hover {color:#fff !important;}

       

        .fc-event-inner {padding:3px;}

        .event-birthday {background:#56458c;border-color:#56458c;}

        .event-campaign {background:#cc9933;border-color:#cc9933;}

        .event-personal {background:#1797c0;border-color:#1797c0;}

    </style>

   

    <apex:sectionHeader title="My Calendar Example"/>

    <apex:outputPanel id="calPanel">

        <apex:form >

            <div id="cal-options">

                <apex:commandButton value="{!IF(includeMyEvents,'Hide My Events','Show My Events')}" action="{!toggleMyEvents}"/>

            </div>

            <div id="cal-legend">

                <ul>

                    <li><span class="event-birthday"></span>Contact's Birthdays</li>

                    <li><span class="event-campaign"></span>Campaigns</li>

                    <li style="{!IF(includeMyEvents,'','display:none')}"><span class="event-personal"></span>My Events</li>

                </ul>

                <div style="clear:both;"><!--fix floats--></div>

            </div>

            <div style="clear:both;"><!--fix floats--></div>

            <div id="calendar"></div>

        </apex:form>

    </apex:outputPanel>

</apex:page>
We recently upgraded from trial to paid production environment, tried to remove unwanted triggers and start from scratch. I noticed that Chatter has a trigger only has 35% coverage, it affects my overall coverage, what can I do with that? It's also confusing that we have 71% overall code coverage in Sandbox, but when deployed it said only 19%, how come? Attached are screenshots:
sandbox coverage
Sandbox Overall Coverage


User-added image
Production Overall Coverage


User-added image
Error Msg

Hi,

My trigger failed to deploy with 100% code coverage. I got help for creating the trigger and test, don't know why it's only 22% coverage at deployment, please help.

Trigger:

trigger SemiMonthly on Pint__c (after update) {
    List<Pint__c> pints = new List<Pint__c>();
   for (Pint__c p : Trigger.new) {
           if (p.Semi_Monthly__c == true ) {
               Pint__c newPint = new Pint__c();
               newPint.Account__c = p.Account__c;                
               pints.add(newPint);
        }
    }
   if(pints.size() > 0) insert pints;
}

Test:

@isTest
public class TestSemiMonthly
{
    static testMethod void insertNewPint()
    {
        // All these records created in your test method are only valid for the tests
        // and they do not actually get inserted in the database, nor they're available
        // outside this context
        Account account = new Account();
        account.Name = 'Test Account';
        insert account;
        Pint__c PintToCreate = new Pint__c();
        PintToCreate.Account__c = account.Id; // HERE we need an ID, not a Name
        insert PintToCreate;
        Test.StartTest();
        PintToCreate.Semi_Monthly__c = true;
        update PintToCreate;
        Test.StopTest();
    }
}

Error message:

, Details: Average test coverage across all Apex Classes and Triggers is 22%, at least 75% test coverage is required.


I got this trigger with some help, now I tried to run a test got 0 coverage, please help. When a Pint's field Semi-monthly check box is checked, a new pint is generated.

TRIGGER:

trigger SemiMonthly on Pint__c (after update) {
    List<Pint__c> pints = new List<Pint__c>();
   for (Pint__c p : Trigger.new) {
           if (p.Semi_Monthly__c == true ) {
               Pint__c newPint = new Pint__c();
               newPint.Account__c = p.Account__c;                
               pints.add(newPint);
        }
    }
   if(pints.size() > 0) insert pints;
}

TEST

@isTest
public class TestSemiMonthly {
    static testMethod void insertNewPint() {
      
       Pint__c PintToCreate = new Pint__c();
PintToCreate.Account__c = 'ABC';
insert PintToCreate;
}
}
I have a custom object Pint, I want it create new pint again automatically once a pint's status is Closed.  I got an error message while creating a trigger, please help.

Error Error: Compile Error: Duplicate variable: p (attempt to re-create the variable with type: Pint__c) at line 4 column 32

trigger CreatePin on Pint__c (after update) {
       for (Pint__c p : Trigger.new) {
               if (p.Status == 'Closed') {
                       Pint__c p = new Pint__c();
                       p.Account__c = c.AccountId;                  
               insert p;
        }
        }
        }
Hi All,

Is it possible to change the background of the header (the area above all Tabs) on all pages like? Right now it's blue, we want some other color. Please advise.
Anybody knows how to make the Calendar shows current month by default? It's not convenient to click This Month every time. Anybody knows what coding I should put in for this effect? Below is just for showing the calendar.

<apex:page >
<script language="JavaScript">
function redirect() {
parent.frames.location.replace("https://na11.salesforce.com/00U/c?md0=2014&md1=1&md3=56")
}
redirect();
</script>
</apex:page>
Is it possible to create a case automatically on a regular basis for an Account?

I created an Object Pint which is similar to Case, we want it to be self-generated on a regular basis, say monthly, biweekly.

Thanks.
Hi All,

I created an Object Pint for Payroll Integration, it will show account information and payroll date etc.. We want the Pint to be self generated 5 business days before the payroll date. Say for biweekly payroll. Is there a way to do that? What trigger shall I use? Any suggestion appreciate. 
Hi All,
I created an Object Pint, we want the Pint to be self-generated when a Case is created and the case type is Rate Change, I get error message that invalid type.

trigger AutoCreatePin on Case (after insert) {
       for (Case c : Trigger.new) {
               if (c.Type == 'Rate Change') {
                       Pint p = new Pint();
            p.AccountId = c.AccountId;
                    insert p;
        }
    }
}


Error: Compile Error: Invalid type: Pint at line 4 column 32

Even I change to "Pint_c" it still says invalid type. Anyone can tell me why?

Thanks.
Is it possible to create a case automatically on a regular basis for an Account?

I created an Object Pint which is similar to Case, we want it to be self-generated on a regular basis, say monthly, biweekly.

Thanks.
Hi All,
We created a trigger on FeedComment - a new record under ChatterPost will be created automatically when a comment contains keyword "legal". The test class has error that missing FeedItemId, we're not sure how to get it fix, please help.

Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [FeedItemId]: [FeedItemId]
Stack Trace Class.CommentKeywordlegalTest.insertNewChatterPostTest: line 13, column 1

@isTest
public class CommentKeywordlegalTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem f = new FeedItem();
        f.ParentId = UserInfo.getUserId();
        f.body = 'test';
        insert f;
        FeedComment fc = new FeedComment();
        fc.CommentBody = 'legal test';
        insert fc;
        Test.StopTest();
        System.assertEquals ('legal test', fc.commentbody);
    }
}

TRIGGER:
Trigger CommentKeywordLegal on FeedComment (after insert) {
    List<FeedComment> FeedComments = new List<FeedComment>();
   for (FeedComment f : Trigger.new) {
           if (f.commentbody!=null &&   f.commentbody.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.commentbody;
                     
              insert C;
        }
    }
   }

Hi All,
We created a trigger for Chatter. When a post contains keyword ”legal', a new record under ChatterPost will be generated. We also created Test class but got error, please help, thank you so much.

Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ParentId]: [ParentId]
Stack Trace Class.ChatterPostTest.insertNewChatterPostTest: line 9, column 1


@isTest
public class ChatterPostTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem f = new FeedItem();
        f.Body = 'legal test';
        insert f;
        Test.StopTest();
        System.assertEquals ('legal test', f.body);
    }
}

TRIGGER:
Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body!=null &&   f.body.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                   
              insert C;
        }
    }
   }
Hi All,
We created a trigger for Chatter. When a post contains keyword ”legal', a new record under ChatterPost will be generated. We also created Test class but got error, please help, thank you so much.

Compile Error: Illegal assignment from Schema.SObjectField to Id at line 8 column 9

@isTest
public class ChatterPostTest
{
    static testMethod void insertNewChatterPostTest()
    {
        Test.StartTest();
        FeedItem post = new FeedItem();
        post.ParentId = ChatterPost__c.Id;
        post.Body = 'legal test';
        insert post;
        Test.StopTest();
        System.assertEquals ('legal test', post.body);
    }
}

TRIGGER:
Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body!=null &&   f.body.contains('legal' ) ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                     
              insert C;
        }
    }
   }
Hi All,
We created a trigger on Chatter. If a post mentions “legal" keyword, a new record under ChatterPost object is created automatically. But it's not working, no new record is created, please help.

Trigger ChatterKeywordLegal on FeedItem (after insert) {
    List<FeedItem> FeedItems = new List<FeedItem>();
   for (FeedItem f : Trigger.new) {
           if (f.body == '!legal' ) {
               ChatterPost__c C = new ChatterPost__c();
               c.Description__c = f.body;
                     
              insert C;
        }
    }
   }
Hi All,

We want to send out email alert when certain key words (like legal, tax) are mentioned in Chatter post. We notice Feed Item Trigger, can we use that to achieve this and how? Based on our research it seems Feed Item Trigger is for insert/delete post, can it trigger to send out email alert or create a new record? Ideally it can trigger to send out email alert, if not we're thinking to create a process like this, when someone mentions "legal" in the post, trigger will fire to create a record under a custom object we build and subsequently send out email alert by workflow rule. Any suggestions? Thanks.
Hi All,
I created a trigger, so that when a new event is created in Public Calendar a new CalendarEV record will be created automatically. I got error message after running test class that missing required fields, so no code coverage at all. I noticed that both Start and End fields in Event object are required Date/Time fields, so I wonder how to create Date/Time in test class for these two fields so that an event can be created and fire the trigger. Please help.

Error message: System.DmLException: insert failed. First exception on row 0; First error, Required field missing
Stack Trace: Class.CalendarEVTest.insertNewCalendarEV: Line11, colum 1

trigger CalendarEV on Event (after insert) {
List<Event> Events = new List<Event>();
   for (Event e : Trigger.new) {
           if (e.Subject != null ) {
               CalendarEV__c C = new CalendarEV__c();
               c.Name = e.Subject;
               c.Start__c = e.StartDateTime;
               c.End__c = e.EndDateTime;
               c.Location__c = e.Location;
               c.Description__c = e.Description;
                    
              insert C;
        }
    }
   }


@isTest
public class CalendarEVTest
{
    static testMethod void insertNewCalendarEV()
    {
        Test.StartTest();
        Event e = new Event();
        e.Subject = 'Test Event';
        e.Location = 'Test Location';
        e.Description = 'Test Description'; 
        insert e;
        Test.StopTest();
        System.assertEquals ('Test Event', e.Subject);
    }
}
Hi All,
I created a trigger so that when a new event is created in Public Calendar a new record under custom object CalendarEV will be created automatically, I also created the test class, it runs successfully but no code coverage, please help.

trigger CalendarEV on Event (after insert) {
    List<Event> Events = new List<Event>();
   for (Event e : Trigger.new) {
           if (e.Subject != null ) {
               CalendarEV__c C = new CalendarEV__c();
               c.Name = e.Subject;
               c.Start__c = e.StartDateTime;
               c.End__c = e.EndDateTime;
               c.Location__c = e.Location;
               c.Description__c = e.Description;
                
              insert C;
        }
    }
   }


@isTest
public class CalendarEVTest
{
    static testMethod void insertNewCalendarEV()
    {
        Test.StartTest();
        Event event = new Event();
        event.Subject = 'Test Event';
        event.Location = 'Test Location';
        event.Description = 'Test Description';      
        Test.StopTest();
    }
}
Hi All,
We created a custom Object CalendarEV, we want a new record for CalendarEV is created automatically  when a new event is created in Public Calendar. We created below trigger but got error message, please help.

Error: Compile Error: Expression cannot be assigned at line -1 column -1

trigger CalendarEV on Event (after insert) {
    List<Event> Events = new List<Event>();
   for (Event e : Trigger.new) {
           if (Event.Subject != null ) {
               CalendarEV__c C = new CalendarEV__c();
               CalendarEV__c.Name = Event.Subject; 
               CalendarEV__c.Location__c = Event.Location;
               CalendarEV__c.Description__c = Event.Description;
                       
              insert C;
        }
    }
   }
We recently upgraded from trial to paid production environment, tried to remove unwanted triggers and start from scratch. I noticed that Chatter has a trigger only has 35% coverage, it affects my overall coverage, what can I do with that? It's also confusing that we have 71% overall code coverage in Sandbox, but when deployed it said only 19%, how come? Attached are screenshots:
sandbox coverage
Sandbox Overall Coverage


User-added image
Production Overall Coverage


User-added image
Error Msg