When I used to create the record in Event object it is showing error like:

> 
> Error: Invalid Data.  
> 
>  Apex trigger General\_Event\_Trigger caused an unexpected exception, contact your administrator: General\_Event\_Trigger: execution of BeforeINsert caused by: System.NullPointerException: Attempt to de-reference a null object: Class.EventClass.updateNewCustomFieldsEvent: line 369, column 1
> 
> 
> 

Trigger code:

```
trigger General_Event_Trigger on Event (...)
{
    if (trigger.isBefore)
    {
        if (trigger.isInsert)
        {
            EventClass.updateNewCustomFieldsEvent(trigger.new);
        }
        else if (trigger.isUpdate)
        {
            EventClass.updateNewCustomFieldsEvent(trigger.new);
        }
    }
}

```

Apex class:

```
public static void updateNewCustomFieldsEvent(List<Event> eventList)
{
    for (Event eve : eventList)
    {
        if (Administrators__c.getInstance().Update_field_Last_Modified_End_User__c)
        {
            String userIdString = eve.LastModifiedById;
            eve.Last_Modified_By_End_User__c = userIdString.subString(0, 15);
            eve.Last_Modified_Date_End_User__c = eve.LastModifiedDate;
        }
    }
}

```