• mark.peplow
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

the follow trigger causes an internal error. i have a case outstanding with support but await their feedback. I am trying to count how many bookings have been made for one event. i have batch apex equivalent working no problem but i need realtime update of event totals. i have to use apex as event is a lookup from booking. any ideaas if the apex is wrong anywhere?

 

trigger UpdateEventRegistrantTotal on Booking__c (after insert, after update, after delete) {
Set <id> EventIDs = new Set<id>();

if(Trigger.isInsert || Trigger.isUpdate){
   for(Booking__c Book : trigger.new){
       if(!EventIDs.contains(Book.event__c)){
           EventIDs.add(Book.Event__c);
       }
   }
}
if(Trigger.isDelete){
   for(Booking__c Book: trigger.old){
       if(!EventIDs.contains(Book.Event__c)){
           EventIDs.add(Book.Event__c);
       }
   }
}
 map<Id,Double> EventMap = new map <Id,Double>();

  //Produce a sum of Booking__c and add them to the map
  //use group by to have a single event Id with a single sum value
  for(AggregateResult q : [select Event__c, Count(id)
    from Booking__c where Event__c IN :EventIDs group by Event__c]){
      EventMap.put((Id)q.get('Event__c'),(Double)q.get('expr0'));
  }

  List<Uni_Event__c> EventsToUpdate = new List<Uni_Event__C>();

  //Run the for loop on event using the non-duplicate set of event Ids
  //Get the sum value from the map and create a list of events to update
  for(Uni_Event__C E : [Select Id, No_of_Registrants__c from Uni_Event__c where Id IN :EventIds]){
    Double NoRegistrants = EventMap.get(E.Id);
    E.No_of_Registrants__c = NoRegistrants;
    EventsToUpdate.add(E);
  }

  update EventsToUpdate;


}

 

cheers

Requirement as follows, any ideas how this could be accomplished:

 

contact centre agent presses send email button on case pagelayout to communicate with a customer about a complaint they raised. However, not all agents have permission to send an email without prior approval of email content. We cant allow the agent to decide themselves whether to seek approval or not. Salesforce.com needs to perform the following actions upon send email button being pressed:

 

  1. check if user has sufficient permission to send without approval, if so, send email, attach to case activity history
  2. if user doesnt have approval, route suggested email text through an approval process whereby supervisor approves
  3. once supervisor approves, email sent out and activity history updated.
  4. if email text rejected, notify case owner, who starts the process again

 

appreciate some ideas of how to accomplish.

 

thanks

 

 

I've been tasked with the following:

 

1.  Identify all assets with an Install Date of Today.

2.  Identify the Contact and Public Group Users associated with the Asset.

3.  Email all identified people with details about their asset.

 

Because of the Salesforce limits of only being able to send out 10 emails and online invoke 100 SOQL statements, I have not been able to find logic that will successfully satisfy this requirement.

 

I was going to use Mass Email, but it will not work with WhatIds of Assets (not will it allow me to connect users to the Asset).

 

I have had success in sending the email through a trigger when the Install Date is entered line by line, but any Mass Updates fail because of the limits mentioned and the requirement being to identify the individuals and Information per Asset Record.

 

Any assistance would be greatly appriciated.

the follow trigger causes an internal error. i have a case outstanding with support but await their feedback. I am trying to count how many bookings have been made for one event. i have batch apex equivalent working no problem but i need realtime update of event totals. i have to use apex as event is a lookup from booking. any ideaas if the apex is wrong anywhere?

 

trigger UpdateEventRegistrantTotal on Booking__c (after insert, after update, after delete) {
Set <id> EventIDs = new Set<id>();

if(Trigger.isInsert || Trigger.isUpdate){
   for(Booking__c Book : trigger.new){
       if(!EventIDs.contains(Book.event__c)){
           EventIDs.add(Book.Event__c);
       }
   }
}
if(Trigger.isDelete){
   for(Booking__c Book: trigger.old){
       if(!EventIDs.contains(Book.Event__c)){
           EventIDs.add(Book.Event__c);
       }
   }
}
 map<Id,Double> EventMap = new map <Id,Double>();

  //Produce a sum of Booking__c and add them to the map
  //use group by to have a single event Id with a single sum value
  for(AggregateResult q : [select Event__c, Count(id)
    from Booking__c where Event__c IN :EventIDs group by Event__c]){
      EventMap.put((Id)q.get('Event__c'),(Double)q.get('expr0'));
  }

  List<Uni_Event__c> EventsToUpdate = new List<Uni_Event__C>();

  //Run the for loop on event using the non-duplicate set of event Ids
  //Get the sum value from the map and create a list of events to update
  for(Uni_Event__C E : [Select Id, No_of_Registrants__c from Uni_Event__c where Id IN :EventIds]){
    Double NoRegistrants = EventMap.get(E.Id);
    E.No_of_Registrants__c = NoRegistrants;
    EventsToUpdate.add(E);
  }

  update EventsToUpdate;


}

 

cheers

I am new to SalesForce and really do not have any experience with Apex Coding. My company wants to be able to automatically generate a Renewal Opportunity when Stage is set to Closed Won. We have a 7 Record Types for Opportunities ("New Sales : New Systems", "New Sales : Services Only", "Active Client : Renewal", "Active Client : New System", Active Client : Services Only", "Debook - Full", and "Debook - Partial") and out of those 7,  the first 5 would need to generate a Renewal Opportunity with a Record Type "Active Client : Renewal". I saw that there were a few blogs about cloning the opportunity but in my case that would not work due to the fact Record Type needs to change so does many of the fields. Also, I wouldn't need to map the Opportunity Products from the original Opportunity.

 

Please if anyone can help me. It's greatly appreciated!