You need to sign in to do that
Don't have an account?
SarikaP
Best practice to code: To Add Terms & Conditions based on Quote Amount
We have a custom object "Terms & Conditions - Quote'.
Based on the "Amount" of the quote, I have to delete certain 'T&C' from the custom object and add other 'T&C' respectively.
The T&C's are linked to the product, whenever a lineitem is added, all product related T&C's are added. But now we want to add further customization to check the amount too. Based on final amount of quote, T&C's can change.
Based on the "Amount" of the quote, I have to delete certain 'T&C' from the custom object and add other 'T&C' respectively.
The T&C's are linked to the product, whenever a lineitem is added, all product related T&C's are added. But now we want to add further customization to check the amount too. Based on final amount of quote, T&C's can change.
If so, you may only have to add a conditional statement and collect a list of T&C to delete and another list to insert.
something like this,
1. list<Terms _Conditions _Quote__c> TandCToDelete = new list <Terms _Conditions _Quote__c>();
2. list<Terms _Conditions _Quote__c> TandCToInsert = new list <Terms _Conditions _Quote__c>();
3. In SOQL query the Amount field
4. Loop through all records in trigger.new for (Terms _Conditions _Quote__c tc : trigger.new){
5. if (Amount > 1000){
TandCToDelete.add(tc.Id);
} else{
TandCToInsert .add(tc.id)
}
insert TandCToInsert ;
delete TandCToDelete .
}
from your description it seems like you would use a After Update trigger.
There are pros and cons of using Process Builder over Trigger (ref: https://blogs.perficient.com/2017/06/13/when-to-use-process-builder-or-apex-triggers-to-automate/)