• alextc78
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I'm trying to create a very simple Apex trigger that will do different actions on an Opportunity Product deletion, depending on which product it is.
I"m encountering a very basic problem and I'm sure I'm just missing something simple here? any guidance would be greatly appreciated.

Apex Trigger:
trigger OppProdDelete on OpportunityLineItem (after delete) {
     for(OpportunityLineItem prod : Trigger.Old) {
          system.debug('OppProdDelete: Product2.Name=' + prod.Product2.Name); // option 1 - gives me null
         system.debug('OppProdDelete: Product2.Name=' + prod.PricebookEntry.Product2.Name); // option 2 - gives me null
}
I tried both option 1 and 2 above to get the product name so I can take the appropriate actions, but both return NULL. How do I reference the product name?

Thanks,
​​​​​​​Alex
Hi,
I'm trying to use a map as a static set of values, something akin to a literal, and want to use different values for the 'literal' in different sections of code. What I would like to do is something like this:
Map<String,List<String>> x;
x = new Map<List<String>>{'key1' => new List<String>{'a', 'b', 'c'}, etc};
// stuff using x as list of literals
x = new Map<List<String>>{'key1' => new List<String>{'d', 'e', 'f'}, etc};
// stuff using x as list of different literals
now my question is how this will behave in apex - whether this will create a memory leak? when I instantiate the same map the second time, does the memory get freed from my first 'instance'? I haven't coded in 18 years, and that was in C where I had to be more explicit with my memory.
I could just create multiple Maps, but it seems unnecessary when each of these sets are used mutually exclusively, and i have a perfectly good Map sitting there already.
thanks in advance!
I'm trying to create a very simple Apex trigger that will do different actions on an Opportunity Product deletion, depending on which product it is.
I"m encountering a very basic problem and I'm sure I'm just missing something simple here? any guidance would be greatly appreciated.

Apex Trigger:
trigger OppProdDelete on OpportunityLineItem (after delete) {
     for(OpportunityLineItem prod : Trigger.Old) {
          system.debug('OppProdDelete: Product2.Name=' + prod.Product2.Name); // option 1 - gives me null
         system.debug('OppProdDelete: Product2.Name=' + prod.PricebookEntry.Product2.Name); // option 2 - gives me null
}
I tried both option 1 and 2 above to get the product name so I can take the appropriate actions, but both return NULL. How do I reference the product name?

Thanks,
​​​​​​​Alex
Hi,
I'm trying to use a map as a static set of values, something akin to a literal, and want to use different values for the 'literal' in different sections of code. What I would like to do is something like this:
Map<String,List<String>> x;
x = new Map<List<String>>{'key1' => new List<String>{'a', 'b', 'c'}, etc};
// stuff using x as list of literals
x = new Map<List<String>>{'key1' => new List<String>{'d', 'e', 'f'}, etc};
// stuff using x as list of different literals
now my question is how this will behave in apex - whether this will create a memory leak? when I instantiate the same map the second time, does the memory get freed from my first 'instance'? I haven't coded in 18 years, and that was in C where I had to be more explicit with my memory.
I could just create multiple Maps, but it seems unnecessary when each of these sets are used mutually exclusively, and i have a perfectly good Map sitting there already.
thanks in advance!