• Amanda Ream
  • NEWBIE
  • 65 Points
  • Member since 2014


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 20
    Replies
I am trying to write a trigger on the Events object that copies from the standard description field (32,000 char) to a custom field (255 char). I am doing this because SF does not allow fields with more than 255 characters to be pulled into reports.I first tried to do this with a workflow but there was an issue that system wasn't recognizing the changes on edit (I filed a case with SF). They provided a workaround solution but I thought it would be easier to just write a trigger. I have the trigger written but I am getting the error "expecting semi-colon, found ')'" on the for line. Does anyone know why this is occuring?

trigger EventUpdate on Event (before insert, before update) {
        for (Event a = Trigger.new){
            List<Event,Id> Event = new List<Id>([SELECT Id from Event where Id IN : trigger.newList.keySet() ]);
    
                    if (event.Description != null){
                      a.customfield__c = event.Description;
                        } else {
                                a.customfield_copy__c = null;
        }
    }
}

 
I am trying to create a trigger that creates a new user record when a custom object picklist is set to 'in progress'. I am getting an error that says "Illegal variable declaration: newUser.FirstName" Can anyone help me out and tell me what this error means? Here is the whole trigger, the bolded line is causing the error:

trigger AutoUserCreate on User (after update) {
    List<User> UserList = new List<User>();
    for( Support_Request__c sr : Trigger.new) {
       if (sr.status__c == 'in progress'){
    User newUser = new User ();
    string newUser.FirstName = Support_Request__c.First_Name__c;
    string newUser.LastName = Support_Request__c.Last_Name__c;
    insert UserList;
    }
   }
}
We are in the process of cosolidating profiles (taking it from about 10 down to 1) and I need to reassign the new profile to about 400 users. This is going to be very tedious if I have to do it one by one but I can't figure out another way to do it. I looked into inline editing, data loader, and apps but nothing seems to be available to make this kind of change en masse. Has anyone else done this before and if so, did you have to do it manually?
I am an APEX newbie trying super hard to teach myself to code but this challenge is proving pretty difficult for me. The situtation is that we have a hierarchial lookup relationship in Opportunities where child Opportunities can be linked to parents. I have found that it is possible to write a trigger to do a roll-up summary from a lookup to another object but I have not found anything that says it is possible in the context of hierarchial lookups. So my first questions is, is this possible?

If so, I found some sample code on this site (http://blog.jeffdouglas.com/2009/07/30/roll-up-summary-fields-with-lookup-relationships-part-1/) that demostrates how to do this between two separate objects but I am having a little trobule translating. This is pretty complex compared to the triggers I have been able to write before so my second question pertains to a section of the code I don't understand. What exactly is the bolded part of the code doing? I have read about for loops and if statements but this is more complex than anything I have ever seen. Any help is much appreciated :)

trigger InventoryItemRollup on Inventory_Item__c (after delete, after insert, after update) {

Set<id> shipmentIds = new Set<id>();
List<shipment__c> shipmentsToUpdate = new List<shipment__c>();

for (Inventory_Item__c item : Trigger.new)
shipmentIds.add(item.Shipment__c);

if (Trigger.isUpdate || Trigger.isDelete) {
for (Inventory_Item__c item : Trigger.old)
shipmentIds.add(item.Shipment__c);

}
// get a map of the shipments with the number of items
Map<id,Shipment__c> shipmentMap = new Map<id,Shipment__c>([select id, items__c from Shipment__c where id IN :shipmentIds]);

// query the shipments and the related inventory items and add the size of the inventory items to the shipment's items__c
for (Shipment__c ship : [select Id, Name, items__c,(select id from Inventory_Items__r) from Shipment__c where Id IN :shipmentIds]) {

shipmentMap.get(ship.Id).items__c = ship.Inventory_Items__r.size();
// add the value/shipment in the map to a list so we can update it
shipmentsToUpdate.add(shipmentMap.get(ship.Id)); }

update shipmentsToUpdate;
}
I am an APEX VisualForce newbie trying to add a mapping VF page to a Custom Object. I copied and pasted some code I found on the answers community for Standard Object (Accounts) and was able to get it to work. Now I am trying to modify the code to work on a Custom Object (Equipment) and it is erroring out on line 1. First I got the error "Equipment__c standard controller doesn't exist" which I think was because I forgot one of the underscores between Equipment and the c. Now I am getting the error "Data type not supported". Any suggestion or help is much appreciated!

<apex:page standardController="Equipment__c">
<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: 8,
    mapTypeId: google.maps.MapTypeId.MAP,
    mapTypeControl: true
  }
 
  var map;
  var marker;
 
  var geocoder = new google.maps.Geocoder();
  var address = "{!Equipment__c.GeoLocationText__c}";
 
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Equipment__c.Equipment_Address__c}</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);
        map.panBy(0,200);
       
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Equipment__c.Equipment_Address__c}"
        });
       
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(map, 'zoom_changed', function() {
          if (this.getZoom() < 8) this.setZoom(8);
        });
       
      }
     
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Equipment__c.Equipment_Address__c}'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>
This is the error I received:

"All components failed Version Compatibility Check.
Every component in this change set requires the "31.0" or higher platform version. Please select an organization with a platform version of "31.0" or higher"

What do I do in this situation, wait until Production has been upgraded to Summer 14'?
I am trying to deploy a change set that contains some custom fields, a page layout, and a few validation rules. My change set will not deploy because I am getting the following error: "In field: page - no ApexPage named ChangeinPLValue found". I don't understand what this means or where I should go to look for the error. Is it in an APEX code somewhere? Any help would be much appreciated. Thanks!
Hello Everyone,
I am an APEX newbie trying to create a trigger that posts when an Opp is won. I have no other requirements besides that the when an Opportunity is updated to the won stage, it posts a pedesigned message to a specific Chatter Group. I took the code from another post (https://developer.salesforce.com/forums/ForumsMain?id=906F00000009AFJIA2) and tried to modify it to do just that but I am running into a problem in the IDE at the "for" line, with the error stating "Save error: Loop must iterate over collection type: Boolen". I tried to add an else statement to break and exit the loop but that gave me a bracket error. Am I totally off base here? Should I pulling a list first for the function to iterate over? Any help would be much appreciated! Thanks!

trigger ChatterPostWonOpp on Opportunity (after update) {

String status;
String OppAccName;
String OppOwnerName;

FeedItem post = new FeedItem();
  
    for(Opportunity o : Trigger.isupdate) {
                if(o.IsWon == true ) //This will be executed on new record insertion when Opp is won
                    for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity])
                     {
                        OppAccName = oppty.Account.Name;
                        OppOwnerName = oppty.Owner.Name;
                      }  
                
                    status = OppOwnerName + ' just won ' + OppAccName + ' for ' + o.Amount + '!';

                    post.ParentId = '0F9g00000008b7c';
                    post.Title = o.Name;
                    post.Body = status;
                  
                    insert post;
          }
    }
I am trying to write a trigger on the Events object that copies from the standard description field (32,000 char) to a custom field (255 char). I am doing this because SF does not allow fields with more than 255 characters to be pulled into reports.I first tried to do this with a workflow but there was an issue that system wasn't recognizing the changes on edit (I filed a case with SF). They provided a workaround solution but I thought it would be easier to just write a trigger. I have the trigger written but I am getting the error "expecting semi-colon, found ')'" on the for line. Does anyone know why this is occuring?

trigger EventUpdate on Event (before insert, before update) {
        for (Event a = Trigger.new){
            List<Event,Id> Event = new List<Id>([SELECT Id from Event where Id IN : trigger.newList.keySet() ]);
    
                    if (event.Description != null){
                      a.customfield__c = event.Description;
                        } else {
                                a.customfield_copy__c = null;
        }
    }
}

 
I am trying to create a trigger that creates a new user record when a custom object picklist is set to 'in progress'. I am getting an error that says "Illegal variable declaration: newUser.FirstName" Can anyone help me out and tell me what this error means? Here is the whole trigger, the bolded line is causing the error:

trigger AutoUserCreate on User (after update) {
    List<User> UserList = new List<User>();
    for( Support_Request__c sr : Trigger.new) {
       if (sr.status__c == 'in progress'){
    User newUser = new User ();
    string newUser.FirstName = Support_Request__c.First_Name__c;
    string newUser.LastName = Support_Request__c.Last_Name__c;
    insert UserList;
    }
   }
}
We are in the process of cosolidating profiles (taking it from about 10 down to 1) and I need to reassign the new profile to about 400 users. This is going to be very tedious if I have to do it one by one but I can't figure out another way to do it. I looked into inline editing, data loader, and apps but nothing seems to be available to make this kind of change en masse. Has anyone else done this before and if so, did you have to do it manually?
I am an APEX newbie trying super hard to teach myself to code but this challenge is proving pretty difficult for me. The situtation is that we have a hierarchial lookup relationship in Opportunities where child Opportunities can be linked to parents. I have found that it is possible to write a trigger to do a roll-up summary from a lookup to another object but I have not found anything that says it is possible in the context of hierarchial lookups. So my first questions is, is this possible?

If so, I found some sample code on this site (http://blog.jeffdouglas.com/2009/07/30/roll-up-summary-fields-with-lookup-relationships-part-1/) that demostrates how to do this between two separate objects but I am having a little trobule translating. This is pretty complex compared to the triggers I have been able to write before so my second question pertains to a section of the code I don't understand. What exactly is the bolded part of the code doing? I have read about for loops and if statements but this is more complex than anything I have ever seen. Any help is much appreciated :)

trigger InventoryItemRollup on Inventory_Item__c (after delete, after insert, after update) {

Set<id> shipmentIds = new Set<id>();
List<shipment__c> shipmentsToUpdate = new List<shipment__c>();

for (Inventory_Item__c item : Trigger.new)
shipmentIds.add(item.Shipment__c);

if (Trigger.isUpdate || Trigger.isDelete) {
for (Inventory_Item__c item : Trigger.old)
shipmentIds.add(item.Shipment__c);

}
// get a map of the shipments with the number of items
Map<id,Shipment__c> shipmentMap = new Map<id,Shipment__c>([select id, items__c from Shipment__c where id IN :shipmentIds]);

// query the shipments and the related inventory items and add the size of the inventory items to the shipment's items__c
for (Shipment__c ship : [select Id, Name, items__c,(select id from Inventory_Items__r) from Shipment__c where Id IN :shipmentIds]) {

shipmentMap.get(ship.Id).items__c = ship.Inventory_Items__r.size();
// add the value/shipment in the map to a list so we can update it
shipmentsToUpdate.add(shipmentMap.get(ship.Id)); }

update shipmentsToUpdate;
}
I am an APEX VisualForce newbie trying to add a mapping VF page to a Custom Object. I copied and pasted some code I found on the answers community for Standard Object (Accounts) and was able to get it to work. Now I am trying to modify the code to work on a Custom Object (Equipment) and it is erroring out on line 1. First I got the error "Equipment__c standard controller doesn't exist" which I think was because I forgot one of the underscores between Equipment and the c. Now I am getting the error "Data type not supported". Any suggestion or help is much appreciated!

<apex:page standardController="Equipment__c">
<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: 8,
    mapTypeId: google.maps.MapTypeId.MAP,
    mapTypeControl: true
  }
 
  var map;
  var marker;
 
  var geocoder = new google.maps.Geocoder();
  var address = "{!Equipment__c.GeoLocationText__c}";
 
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Equipment__c.Equipment_Address__c}</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);
        map.panBy(0,200);
       
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Equipment__c.Equipment_Address__c}"
        });
       
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(map, 'zoom_changed', function() {
          if (this.getZoom() < 8) this.setZoom(8);
        });
       
      }
     
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Equipment__c.Equipment_Address__c}'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>
This is the error I received:

"All components failed Version Compatibility Check.
Every component in this change set requires the "31.0" or higher platform version. Please select an organization with a platform version of "31.0" or higher"

What do I do in this situation, wait until Production has been upgraded to Summer 14'?
Hi,

I am trying to deploy few reports and dashboards to a fullcopy sandbox 'fc' from another fullcopy sandbox via changeset and I am getting the following error message for dashboards.

Too many username matches for abc@gmail.com. The possible matches are abc@gmail.com.fc, abc@gmail.com; edit the username to match only one.

What des this mean?
I am trying to deploy a change set that contains some custom fields, a page layout, and a few validation rules. My change set will not deploy because I am getting the following error: "In field: page - no ApexPage named ChangeinPLValue found". I don't understand what this means or where I should go to look for the error. Is it in an APEX code somewhere? Any help would be much appreciated. Thanks!
Hello Everyone,
I am an APEX newbie trying to create a trigger that posts when an Opp is won. I have no other requirements besides that the when an Opportunity is updated to the won stage, it posts a pedesigned message to a specific Chatter Group. I took the code from another post (https://developer.salesforce.com/forums/ForumsMain?id=906F00000009AFJIA2) and tried to modify it to do just that but I am running into a problem in the IDE at the "for" line, with the error stating "Save error: Loop must iterate over collection type: Boolen". I tried to add an else statement to break and exit the loop but that gave me a bracket error. Am I totally off base here? Should I pulling a list first for the function to iterate over? Any help would be much appreciated! Thanks!

trigger ChatterPostWonOpp on Opportunity (after update) {

String status;
String OppAccName;
String OppOwnerName;

FeedItem post = new FeedItem();
  
    for(Opportunity o : Trigger.isupdate) {
                if(o.IsWon == true ) //This will be executed on new record insertion when Opp is won
                    for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity])
                     {
                        OppAccName = oppty.Account.Name;
                        OppOwnerName = oppty.Owner.Name;
                      }  
                
                    status = OppOwnerName + ' just won ' + OppAccName + ' for ' + o.Amount + '!';

                    post.ParentId = '0F9g00000008b7c';
                    post.Title = o.Name;
                    post.Body = status;
                  
                    insert post;
          }
    }

Hi, 

I am looking to send trigger a chatter alert in a group when an opportunity is changed to Closed Won. We are currently using email alerts (AND( ISCHANGED(StageName), Probability = 1, NOT(Owner.Id = "005d0000001TUC8")) but would like to move the interaction to chatter: 

 

Below is my attempt but

 

1. When I try this I get the error - Compile Error: unexpected token: insert at line 26 column 8 

2.As it is in the workflow - I would like to have one person's opportunitiy's (NOT(Owner.Id = 005d0000001TUC8) not trigger this workflow for privacy reasons

 

Could anyone help me clean this up? Thank you so much!

 

trigger ChatterWonOpportunity on Opportunity (after insert, after update) {

String status;
String OppAccName;
//Decimal OppAmount;
FeedItem post = new FeedItem();
    
    for(Opportunity o : Trigger.new) {
        if(Trigger.isInsert) {
                               if(o.IsWon == true && Trigger.oldMap.get(o.id).IsWon == false) {
                    for (Opportunity oppty : [SELECT Account.Name FROM Opportunity WHERE Id =:o.Id] ) {
                        OppAccName = oppty.Account.Name;
                    }
                   o.owner +' just won' + OppAccName + 'for' o.expectedrevenue + ‘!';
                    }
                    else {
                        return;
                    }
                }
            
            post.ParentId = //0F9K000000005LR
            post.Title = o.Name;
            post.Body = status;
            }
        }
        insert post;
    }
}

 

  • August 06, 2013
  • Like
  • 0