You need to sign in to do that
Don't have an account?
BillPowell__c
Assign index # to quote line items help??
I'd like to find a way to dynamically assign a "Line Number" to a quote line based on certain criteria.
For instance, If I have 100 lines on my quote, and only want to show 20 of them and assign a line # 1-20 to those 20 items, how can I accomplish this? The "hidden" quote line items will not show up on the quote template since they are for internal configuration use only, but are throwing off the line #'s since they are hidden, its causing the line #'s for shown items to jump around.
I'm assuming this may be an "After" trigger on the quote object? I don't know code well but I should be able how to write the trigger if need be with some guidance.
Am I on the right path of having an "After" trigger and having it cycle through "quote lines" and if "Core Product" is checked and "Line Number" is blank, assign it 1, then go through the loop again and have X++ so the next quote line if it meets criteria, is 2, and so on and so on?
Thoughts? Thanks for your help
For instance, If I have 100 lines on my quote, and only want to show 20 of them and assign a line # 1-20 to those 20 items, how can I accomplish this? The "hidden" quote line items will not show up on the quote template since they are for internal configuration use only, but are throwing off the line #'s since they are hidden, its causing the line #'s for shown items to jump around.
I'm assuming this may be an "After" trigger on the quote object? I don't know code well but I should be able how to write the trigger if need be with some guidance.
Am I on the right path of having an "After" trigger and having it cycle through "quote lines" and if "Core Product" is checked and "Line Number" is blank, assign it 1, then go through the loop again and have X++ so the next quote line if it meets criteria, is 2, and so on and so on?
Thoughts? Thanks for your help
You are spot on, after trigger all the way. There is a trick though. Salesforce tells you that you can't update the records in the trigger in an after trigger so see the code sample. I only spent 25 minutes writing this so it's very rough but for sure will get you going. Sorry for any error-goodies I may have left in there. Let me know how it goes.
If I mis-understood this at all let me know. This will increment Quote Line Items starting from 1 within each Quote... and if there were existing line items with numbers already (gaps and all) it will still add 1 to the highest record.
Your unit test should simply create a Quote, insert various Quote Line Items and perform different things like deletes, adds etc. Then Assert that the correct outcome is present.
Also, this isn't a proper "trigger pattern" which ultimately you should be doing for best practice. Typical pattern puts all the business/code logic into another class and the trigger is just a shell to pass trigger.new and trigger.newMap to the class method. You'd also want to add custom settings so that you can disable the trigger with a click as needed.