• mojave
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 7
    Replies

Hi,

 

Does anyone know why I would get a null Product2Id out of the following debug statement?

 

for (OpportunityLineItem oli : Trigger.new){
  system.debug ('product is: ' + oli.PricebookEntry.Product2Id);

  }

 

I hope to one day to go so far as to access the name of the product, not just the ID.

 

I had some advice on how to do that, but my syntax must not be right.

 

Thanks for any tips,

Kevin

 

 

  • April 27, 2009
  • Like
  • 0

How does one access a product2's name (description) within an OpportunityLineItem?

 

I don't care about the product's ID or price book information--just the product's name.  I haven't figured out how to do this yet, though it seems like it should be simple...

 

I'm building (hopefully some day) a OpportunityLineItem trigger to update a field elsewhere based on whether or certain products appear in line items.

 

Thanks,

Kevin

  • April 23, 2009
  • Like
  • 0

I'm writing a trigger that will cause some data updates to happen when an Opportunity has certain products added or changed.

 

I think the trigger should run on Opportunity (after insert, after update), but I can't seem to access data like Opportunity.OpportunityLineItem[x].productName when triggering on the opportunity.

 

If OpportunityLineItems aren't a child of Opportunity, how does one access that data?  I guess I'm not approaching this correctly and don't understand the Opportunity object yet.

 

Thanks,

Kevin

  • April 15, 2009
  • Like
  • 0

I would normally use a "for" loop to go through trigger-submitted data.  It works, but that kind of code won't pass the test in this case because it will generate too many queries.

 

So I'm trying to dump the results of a query into a list, but system doesn't like this, apparently because the trigger data is a list:

 

accts.add([select ID, custom__c from account where id=:trigger.new.Account__c]);

 

It's probably obvious that I'm missing something about how these mysterious bulk queries work....

 

 

Thanks,

 

Kevin

  • April 02, 2009
  • Like
  • 0

Is there a way to check a variable's value during trigger execution?  I use alerts and echo statements in javascript and PHP code to accomplish this, but haven't seen anything yet like this for apex.

 

I've written some trigger code that compiles OK, but it doesn't actually do what I want it to do, so i need to debug this somehow.

 

As a newbie, I've probably missed something really obvious here!

 

Thanks,

Kevin

 

  • April 01, 2009
  • Like
  • 0

Hi,

 

Does anyone know why I would get a null Product2Id out of the following debug statement?

 

for (OpportunityLineItem oli : Trigger.new){
  system.debug ('product is: ' + oli.PricebookEntry.Product2Id);

  }

 

I hope to one day to go so far as to access the name of the product, not just the ID.

 

I had some advice on how to do that, but my syntax must not be right.

 

Thanks for any tips,

Kevin

 

 

  • April 27, 2009
  • Like
  • 0

How does one access a product2's name (description) within an OpportunityLineItem?

 

I don't care about the product's ID or price book information--just the product's name.  I haven't figured out how to do this yet, though it seems like it should be simple...

 

I'm building (hopefully some day) a OpportunityLineItem trigger to update a field elsewhere based on whether or certain products appear in line items.

 

Thanks,

Kevin

  • April 23, 2009
  • Like
  • 0

I'm writing a trigger that will cause some data updates to happen when an Opportunity has certain products added or changed.

 

I think the trigger should run on Opportunity (after insert, after update), but I can't seem to access data like Opportunity.OpportunityLineItem[x].productName when triggering on the opportunity.

 

If OpportunityLineItems aren't a child of Opportunity, how does one access that data?  I guess I'm not approaching this correctly and don't understand the Opportunity object yet.

 

Thanks,

Kevin

  • April 15, 2009
  • Like
  • 0

I would normally use a "for" loop to go through trigger-submitted data.  It works, but that kind of code won't pass the test in this case because it will generate too many queries.

 

So I'm trying to dump the results of a query into a list, but system doesn't like this, apparently because the trigger data is a list:

 

accts.add([select ID, custom__c from account where id=:trigger.new.Account__c]);

 

It's probably obvious that I'm missing something about how these mysterious bulk queries work....

 

 

Thanks,

 

Kevin

  • April 02, 2009
  • Like
  • 0

Is there a way to check a variable's value during trigger execution?  I use alerts and echo statements in javascript and PHP code to accomplish this, but haven't seen anything yet like this for apex.

 

I've written some trigger code that compiles OK, but it doesn't actually do what I want it to do, so i need to debug this somehow.

 

As a newbie, I've probably missed something really obvious here!

 

Thanks,

Kevin

 

  • April 01, 2009
  • Like
  • 0