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
Projjwal LahiriProjjwal Lahiri 

can any one share the apex trigger code on discount approval?

Leo10Leo10
Hi Projjwal Lahiri 
Can you explain more about discount approval object. I think, discount approval object is a  custom object. If you can give a clear picture of your object, may be I can help you.

Thank you 
 
Projjwal LahiriProjjwal Lahiri
Hi NABEEL KT, Discount Approval is not a custom object. See, I have created an opportunity and there I added a product. So, I can also add the discount on that particular product. Now I can generate the quote. So, here I want when I am creating a quote, if the discount is greater than suppose 20% then it will automatically go to the submit for approval, after approved the quote will be generated and if the discount is not greater than 20% then it will not go to the submit for approval, the quote will be generated automatically. So, for this I want the trigger code to do it automatically. Warm Regards, Projjwal Lahiri
Leo10Leo10
Hi,
If this is the scenario you can go with process builder instead of trigger. Have you tried with process builder?
 
Projjwal LahiriProjjwal Lahiri
Hi, I tried with the process builder and approval process. But still it is not working. Get Outlook for Android
Leo10Leo10
Hi
have you tried to write trigger? if yes, can you send me the code? I didn't understand your full scenario.

Thank you.
Projjwal LahiriProjjwal Lahiri
Hi, This is the trigger code I used, Trigger trigger approveDiscount on Quote (after update,after insert) { for (Quote quotes : Trigger.new) { if (quotes.Discount < 20) { Approval.ProcessSubmitRequest approvalRequest = new Approval.ProcessSubmitRequest(); approvalRequest.setComments('Discount Submitted for approval'); approvalRequest.setObjectId(quotes.QuoteNumber); Approval.ProcessResult approvalResult = Approval.process(approvalRequest); System.debug('offer submitted for approval successfully: '+approvalResult .isSuccess()); } } } Warm Regards, Projjwal Kr. Lahiri