You need to sign in to do that
Don't have an account?
Approach for automatically inserting records
Hi,
I was looking for some opinion for my approach. The goal is: when a user is entering sales order line items, if they enter certain product code, other related products should get entered. For instance, they enter a line for Product A, then ProductB, ProductC, and ProductD would automatically get entered. Normally I would put this code in the data entry form, but I don't think anything like that is available to me. The only thing I could think of was to use an AfterInsert trigger. My original try at this didn't work because the trigger had too many characters. I could probably code it better, but I want to make sure this Trigger approach is the way to go. One immediate downside is that I have to hardcode the particular product codes inside my trigger code. I'd rather do it with some kind of lookup table.
Any suggestions would be greatly appreciated.
thanks!!
Let me make sure I understand this. If a user adds Product A to an Opportunity as a Line Item you want to automatically add additional products too? (e.g. If I buy a new automobile, you want to also add in the license plate, tank of gas and warranty)
If this is correct, then yes, you want to use an Apex trigger on OpportunityLineItem. Surprised you're getting a too many characters message, this sounds very strange unless you have over 1 million chars of code in your org????
Also, you could easily set up a custom object (AdditionalProducts) to define the rules for this, this would just need to be junction object between Product and PriceBookEntry. Then in your Apex code: