0

I have the following line of code, I don't find the problem, but the line is:

Set<ID> ids = Trigger.newMap().keySet();

trigger Bitacora on Bitacora__c (after insert, after delete, after update) {
    if (Activo.bitacora) return;
    else Activo.bitacora=true;

    if (Trigger.isInsert) {
        Map<ID, Event> eventos = new Map<ID, Event>();        

    for (Bitacora__c bitacora : Trigger.new) {
        Event evento = new Event(Description = bitacora.Descripcion__c,
        EndDateTime = bitacora.FechaHoraFin__c,
        OwnerId = bitacora.OwnerId,
        StartDateTime = bitacora.FechaHoraInicio__c,
        Subject = bitacora.TipoActividad__c,
        IdBitacora__c = bitacora.id);
        eventos.put(bitacora.id, evento);
    }

    insert eventos.values();
    Set<Bitacora__c> bitacoras = new Set<Bitacora__c>();

    Set<ID> ids = Trigger.newMap().keySet();

    bitacoras = [SELECT Id FROM Bitacora__c WHERE Id in :ids];

    for(Bitacora__c bitacora : bitacoras){
        bitacora.IdEvento__c = eventos.get(bitacora.Id).Id;
    }

    update bitacoras;

    }else if (Trigger.isDelete){ 
        for(Bitacora__c bitacora : Trigger.old) {
            Event evento = [SELECT IdBitacora__c FROM Event WHERE IdBitacora__c = :bitacora.id];
            delete evento;
        }
    }else if (Trigger.isUpdate){ 
        for(Bitacora__c bitacora : Trigger.new) {
            Event evento = [SELECT AccountId,
                                    StartDateTime,
                                    EndDateTime,
                                    Subject,
                                    Description,
                                    OwnerId,
                                    IdBitacora__c
                                    FROM Event
                                    WHERE IdBitacora__c=:bitacora.id];
                                        evento.StartDateTime=bitacora.FechaHoraInicio__c;
                                        evento.EndDateTime=bitacora.FechaHoraFin__c;
                                        evento.Subject=bitacora.TipoActividad__c;
                                        evento.Description=bitacora.Descripcion__c;
                                        evento.OwnerId=bitacora.OwnerId;
                                        evento.IdBitacora__c=bitacora.id;
                                        update evento;}
    }
}
1
  • can you post your full code
    – sfdc
    Jun 9, 2014 at 18:05

1 Answer 1

5

It's Trigger.newMap.keySet(); Cheers

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .