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;}
    }
}
  • can you post your full code – sfdc Jun 9 '14 at 18:05
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.