You need to sign in to do that
Don't have an account?
Raymond Airey
Automatically delete a product after Opportunity reaches certain amount?
HI All,
We have decided to include a 'Postage and Handling' fee for all opportunities that are created under $100.
By that I want any opportunity that is created and saved under $100 to automatically added an opportunity product of 'POSTAGEHANDLING' with a price of $9.95.
Currently I have a process in place that automatically adds the freight Product into every opportunity but I need to create an APEX trigger that will delete the same product once the opportunity is greater than $100.
I havent had much experience in Apex so any help would be greatly appreciated.
Ray
We have decided to include a 'Postage and Handling' fee for all opportunities that are created under $100.
By that I want any opportunity that is created and saved under $100 to automatically added an opportunity product of 'POSTAGEHANDLING' with a price of $9.95.
Currently I have a process in place that automatically adds the freight Product into every opportunity but I need to create an APEX trigger that will delete the same product once the opportunity is greater than $100.
I havent had much experience in Apex so any help would be greatly appreciated.
Ray
Below is the sample code to start over you need to change according to your requirements.
Please refer below link
https://developer.salesforce.com/forums/?id=906F000000094FlIAI
Hope this helps you!
If this helps you, please mark it as solved.
Thanks and Regards
Sandhya
Thank you so much for this, its definetely a good start for me.
Looking at the code above, are you able to advise where I specify the ProductID that needs to be deleted from the Opportunity? Would I be setting the ID within these fields? "Set<Id> OppIds = new Set<Id>();" "Set<Id> sProdIds = new Set<Id>();"
Any help is very much appreciated,
Raymond
HI Sandhya,
I have tried a few different ways to insert the productID and all seem to be throwing exceptions.
I am trying to add "PricebookEntry.Product2.ISBN__c.01t6F000005BUc8" as the sProdIds.
Can you point me in the right direct of how the code may look?
Thanks,
Ray
Can you please post your code?
Thanks and Regards
Sandhya