function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shawn Reichner 33Shawn Reichner 33 

Delete existing Quote Lines when Importing Quote Lines

Hello, I am not sure if this is the correct topic to list this under, but I am certain what I am looking for will ulimately need some custom coding.  

What I am being asked to find a potential solution for is for example: An existing quote already has quote lines present.  A User wishes to update said quote by "Importing Quote lines" using an import format.  When the import is used, they wish to have all existing quote lines be deleted and only the new lines from the import remaining.  

Any thoughts on how to possibly achieve this?

Any help would be very much appreciated!

Shawn
Best Answer chosen by Shawn Reichner 33
Abhishek BansalAbhishek Bansal
Hi Shawn,

You need to follow the below steps:
  1. Create one new field on Line Items like Is Imported from Wizard.
  2. Ask the import wizard team to map this field as true for all the records that are imported from wizard.
  3. Add a after insert trigger, check if this field is true. If Yes, store the id of related Quote in a set.
  4. Once the loop is completed, deleted all the line items where Id IN: setOfQuoteIds pouplated in #3.
Let me know if you need any more information or help on this.

Thanks,
Abhishek Bansal.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Phone: +917357512102

All Answers

AmitSoniAmitSoni
I can think of an Before APEX Trigger on Quote Line Item Object. Check if there are any Quote Line Items Exists with the associted Quote, list them all and delete.
Shawn Reichner 33Shawn Reichner 33
I was thinking the same thing, however is there any indication on the quote lines that they were created via the import service? That is my missing piece, any thoughts? Thanks for the help! Get Outlook for iOS
Abhishek BansalAbhishek Bansal
Hi Shawn,

You need to follow the below steps:
  1. Create one new field on Line Items like Is Imported from Wizard.
  2. Ask the import wizard team to map this field as true for all the records that are imported from wizard.
  3. Add a after insert trigger, check if this field is true. If Yes, store the id of related Quote in a set.
  4. Once the loop is completed, deleted all the line items where Id IN: setOfQuoteIds pouplated in #3.
Let me know if you need any more information or help on this.

Thanks,
Abhishek Bansal.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Phone: +917357512102
This was selected as the best answer