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
Raymond AireyRaymond Airey 

Automatically add product based on total?

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.

What (if any) would be the easiest way to achieve this? I have tried using a workflow but couldnt achieve the correct outcome.

Any ideas would be greatly appreicated.

Ray
Best Answer chosen by Raymond Airey
Ravi Dutt SharmaRavi Dutt Sharma
Hey Ray,

Trigger is a piece of code that gets executed whenever a DML event occurs. Triggers are object specific and can handle all the DML events. You can find more information on trigggers here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers.htm

All Answers

rajaraja
Hello Raymond,

Do you want to add product ,If opportunity amount greater than 100 $ or Do you want to update "PostageHandling "  field if amount greater than 100 $?

Regards,
Raja.
Ravi Dutt SharmaRavi Dutt Sharma
Hey Raymond,

You cannot create records through workflow. There are 2 ways to achieve this (ie create a new OpportunityProduct record when Opportunity amount is greter than 100$):

1) Try exploring Process builder. It allows you to create new records. You can keep an entry criteria as if Oppty amount is greater then 100$, then only execute the process builder action. In the action, select create a new record.
2) The second way to achieve this is using a trigger.

Hope this helps. Thanks.
Raymond AireyRaymond Airey
Raymond Airey
HI All,

Due to the backend system we use, we need to add a product rather than using the stock Salesforce field.

Just to clarify, we want to add the $9.95 postage charge to any orders under $100.

I will have a look at the process builder but could you clrify what a trigger is?

Appreicate all of the help,

Ray
 
Ravi Dutt SharmaRavi Dutt Sharma
Hey Ray,

Trigger is a piece of code that gets executed whenever a DML event occurs. Triggers are object specific and can handle all the DML events. You can find more information on trigggers here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers.htm
This was selected as the best answer