• Ben Olsen 12
  • NEWBIE
  • 24 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
running into this error when trying to clone a forecast opportunity with products:     Error: Invalid Data.  Review all error messages below to correct your data. java.lang.NumberFormatException: For input string: "100.0"    But when i'm logged in as the admin I can do this with no problem, and there are no error messages in the opp fields.
I'm getting a syntax error when using this in a validation rule,   any ideas ?      NOT( REGEX(Phone,"[0-9\(\)\s\-\+]"))
Hi, I would like to create a trigger on the ideas object to send an email to all voters/commentors on the particular ID, when a custom field (Idea_Status__c) is updated,    Any help would be awesome,  Here is what I have so far


trigger IdeaTrigger on Idea (after update) {
    
    Set<Id> ideaIds = trigger.newMap.keySet();
    
    Map<Id,List<User>> ideaUserMap = new Map<Id,List<User>>();
    
    for(Id i : ideaIds)
        ideaUserMap.put(i.Id,new List<User>());
    
    for(IdeaComment ic : [SELECT Id, CreatedBy.Id,IdeaId FROM IdeaComment WHERE IdeaId IN :ideaIds]){
        ideaUserMap.get(ic.IdeaId).add(ic.CreatedBy);
    }
    
    for(Vote iv : [SELECT Id, CreatedBy.Id, ParentId FROM Vote WHERE ParentId IN :ideaIds AND Type = 'Up']){
        ideaUserMap.get(iv.ParentId).add(ic.CreatedBy);
    }
    
    //create list of outbound emails
    Messaging.SingleEmailMessage[] messages = new Messaging.SingleEmailMessage[]{};
    
    for(Idea i : Trigger.new){
        
        //Need to check that the custom field has changed on the ideas object
        if(i.Idea_Status__c == oldMap.get(i).Idea_Status__c)
            continue;
        //"merge" fields into template
        String EmailSubject = i.Name;
        String EmailBody = 'Name:' + i.Name;
        emailBody += '\nIdea Id: ' + i.Id;
        //add the rest of the fields you want in the body.
    
        
    
        //for each user, create a template, set the text
        for(User u : ideaUserMap.get(i.Id)){
    
             Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
             email.setTargetObjectId(u.id);
             //email.setOrgWideEmailAddressId(BlackHoleOrgWide);
             email.setSubject(EmailSubject);
             email.setHtmlBody(EmailBody);
             messages.add(email);
        }
    
    }

    //send the list of messages
    Messaging.sendEmail(messages);
    
}
 
running into this error when trying to clone a forecast opportunity with products:     Error: Invalid Data.  Review all error messages below to correct your data. java.lang.NumberFormatException: For input string: "100.0"    But when i'm logged in as the admin I can do this with no problem, and there are no error messages in the opp fields.
I'm getting a syntax error when using this in a validation rule,   any ideas ?      NOT( REGEX(Phone,"[0-9\(\)\s\-\+]"))
Hi, I would like to create a trigger on the ideas object to send an email to all voters/commentors on the particular ID, when a custom field (Idea_Status__c) is updated,    Any help would be awesome,  Here is what I have so far


trigger IdeaTrigger on Idea (after update) {
    
    Set<Id> ideaIds = trigger.newMap.keySet();
    
    Map<Id,List<User>> ideaUserMap = new Map<Id,List<User>>();
    
    for(Id i : ideaIds)
        ideaUserMap.put(i.Id,new List<User>());
    
    for(IdeaComment ic : [SELECT Id, CreatedBy.Id,IdeaId FROM IdeaComment WHERE IdeaId IN :ideaIds]){
        ideaUserMap.get(ic.IdeaId).add(ic.CreatedBy);
    }
    
    for(Vote iv : [SELECT Id, CreatedBy.Id, ParentId FROM Vote WHERE ParentId IN :ideaIds AND Type = 'Up']){
        ideaUserMap.get(iv.ParentId).add(ic.CreatedBy);
    }
    
    //create list of outbound emails
    Messaging.SingleEmailMessage[] messages = new Messaging.SingleEmailMessage[]{};
    
    for(Idea i : Trigger.new){
        
        //Need to check that the custom field has changed on the ideas object
        if(i.Idea_Status__c == oldMap.get(i).Idea_Status__c)
            continue;
        //"merge" fields into template
        String EmailSubject = i.Name;
        String EmailBody = 'Name:' + i.Name;
        emailBody += '\nIdea Id: ' + i.Id;
        //add the rest of the fields you want in the body.
    
        
    
        //for each user, create a template, set the text
        for(User u : ideaUserMap.get(i.Id)){
    
             Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
             email.setTargetObjectId(u.id);
             //email.setOrgWideEmailAddressId(BlackHoleOrgWide);
             email.setSubject(EmailSubject);
             email.setHtmlBody(EmailBody);
             messages.add(email);
        }
    
    }

    //send the list of messages
    Messaging.sendEmail(messages);
    
}