• Nicholas Melonas
  • NEWBIE
  • 20 Points
  • Member since 2014
  • Business Analyst | Marketing Director
  • SunPower by Green Convergence

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 13
    Replies
Hello,

On my custom object "Project" (), I have the custom field, "Status" (MPM4_BASE__Status__c). Whenever this status is updated, I need it to instantly update to the custom "Project Status" field on the Account object (Project_Status__c). I know this can be accomplished with a formula field, but I need this trigger to happen immediately without any edits on the Account, and need the "Project Status" field to remain as a picklist field. How do I write the trigger and class for this? Thanks so much! 
Hello,

I am trying to create an Apex Class for the Apex Trigger below. How would I go about doing this? Here is a link to my original post: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BWej.  Thanks for your help!
 
trigger fillInAccount on MPM4_BASE__Milestone1_Project__c(after insert, after update) {
    Set<Id> oppIds = new Set<Id>();
    
    for(MPM4_BASE__Milestone1_Project__c proj : trigger.new){
        if(proj.Opportunity_Name__c != null){
            oppIds.add(proj.Opportunity_Name__c);
        }
    }
    Map<Id,Opportunity> oppMap = new Map<Id,Opportunity>([Select AccountId from Opportunity where id in :oppIds]);
    
    Set<Id> accIds = new Set<Id>();
    
    for(Opportunity opp : oppMap.values()){
        accIds.add(opp.AccountId);
    }
    
    Map<Id,Account> accMap = new Map<Id,Account>([Select Project__c from Account where Id In :accIds]);//Replace Project__c with your field API name
    
    for(MPM4_BASE__Milestone1_Project__c proj : trigger.new){
        if(oppMap.containsKey(proj.Opportunity_Name__c)) {
            accMap.get(oppMap.get(proj.Opportunity_Name__c).AccountId).Project__c  = proj.id; //Replace Project__c with your field API name
        }
    }
    update accMap.values();
}
Hello,

On my managed custom object called, "Projects" (MPM4_BASE__Milestone1_Project__c), we manually fill in the Opportunity Name (Opportunity_Name__c). However now whenever the opportunity name is filled in on the project object, I want the project to autopopulate the Project Name look-up relationship field (Project__c) on the Account standard object. How do I write this trigger?

Thanks!

Nick
Hello,

On my custom object, "Projects," there is a field we manually fill in that connects it to the Opportunity object. However I also need a look-up relationship field that automatically populates the Account Name and connects the Project to the Account object. Where do I start and how can I do this? Is there a template formula I can use?

Thanks!
 
Hello!

I am trying to create a drip campaign. If leads are in our "Claimed" status, I want emails to be sent out based on the age of the lead. The first email, for example, will be the campaign "Claimed #1" and will be sent out if the status is "Claimed" and it is the first day the lead has been in claimed.

Is it possible for my "Claimed' leads to be filtered in and out of this campaign automatically? For example, I want only leads that are in "Claimed" and the lead age equals "0." Hypothetically, the lead should appear in this campaign automatically on day 1, but on day 2 it should disappear from the campaign and leads that fit the criteria should populate the campaign.

Please let me know if this automation is possible! Thanks so much!
Hello,

I have Google Maps Integration working perfect on Leads and Accounts. However I can't seem to get it work on the Opportunity object. Is this because my address field on the Opportunity is a formula field? Thanks for your help. Seeing Google Map work on Opportunities would be huge for us!
 
<apex:page standardController="Opportunity">
<apex:pageBlock >
<head>
 
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 
 
$(document).ready(function() {
  
  var myOptions = {
    zoom: 19,
    mapTypeId: google.maps.MapTypeId.SATELLITE,
    mapTypeControl: true
  }
  
  var map;
  var marker;
  
  var geocoder = new google.maps.Geocoder();
  var address = "{Billing_Address__c}";
  
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Opportunity.Name}</b>"
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
      
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
      
        //center map
        map.setCenter(results[0].geometry.location);
        
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Opportunity.Name}"
        });
        
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
        
      }
      
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Opportunity.Name}'s address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });
  
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
  
});
</script>
 
<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:500px;
  background:transparent;
}
</style>
 
</head>
 
<body>
<div id="map"></div> 
</body> 
</apex:pageBlock>
</apex:page>

 
Hello,

I have Milestones PM+ for Salesforce. Up until now we have been able to change projects in another user's name as the project owner. However today, this message appeared and it won't allow me to change the project owner to another user. Can someone help? Thanks!

Error: Apex trigger MPM4_BASE.Milestone1_Project_Trigger caused an unexpected exception, contact your administrator: MPM4_BASE.Milestone1_Project_Trigger: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4000000IngfkEAB; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MPM4_BASE.Milestone1_Milestone_Trigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object (MPM4_BASE) : []: (MPM4_BASE)

Thanks,

Nick
I am new to Apex Coding / Triggers and I am stuck. I'm trying to create a trigger where when an event is created with a specific subject line, it automatically populates an "Appointment Date" custom field on the Opportunity object. Where do I begin? Thank you!
Hello,

I am trying to create an Apex Class for the Apex Trigger below. How would I go about doing this? Here is a link to my original post: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BWej.  Thanks for your help!
 
trigger fillInAccount on MPM4_BASE__Milestone1_Project__c(after insert, after update) {
    Set<Id> oppIds = new Set<Id>();
    
    for(MPM4_BASE__Milestone1_Project__c proj : trigger.new){
        if(proj.Opportunity_Name__c != null){
            oppIds.add(proj.Opportunity_Name__c);
        }
    }
    Map<Id,Opportunity> oppMap = new Map<Id,Opportunity>([Select AccountId from Opportunity where id in :oppIds]);
    
    Set<Id> accIds = new Set<Id>();
    
    for(Opportunity opp : oppMap.values()){
        accIds.add(opp.AccountId);
    }
    
    Map<Id,Account> accMap = new Map<Id,Account>([Select Project__c from Account where Id In :accIds]);//Replace Project__c with your field API name
    
    for(MPM4_BASE__Milestone1_Project__c proj : trigger.new){
        if(oppMap.containsKey(proj.Opportunity_Name__c)) {
            accMap.get(oppMap.get(proj.Opportunity_Name__c).AccountId).Project__c  = proj.id; //Replace Project__c with your field API name
        }
    }
    update accMap.values();
}
Hello,

On my managed custom object called, "Projects" (MPM4_BASE__Milestone1_Project__c), we manually fill in the Opportunity Name (Opportunity_Name__c). However now whenever the opportunity name is filled in on the project object, I want the project to autopopulate the Project Name look-up relationship field (Project__c) on the Account standard object. How do I write this trigger?

Thanks!

Nick
I am new to Apex Coding / Triggers and I am stuck. I'm trying to create a trigger where when an event is created with a specific subject line, it automatically populates an "Appointment Date" custom field on the Opportunity object. Where do I begin? Thank you!