You can find the opportunity and its line item trigger details for contract renewals.
Opportunity trigger details
- You can run contact renewals, only if the Enable Contract Renewal Transaction Sync box is checked in the Contract Renewals Sync section > Advanced settings.
- After you check the Enable Contract Renewal Transaction Sync checkbox, the checkbox is stored in the Salesforce custom settings.
- Based on the custom settings, the Salesforce trigger checks if the contract renewals are enabled or disabled and accordingly it runs the appropriate flow.
- Contract renewal functionality (before trigger):
- OrderType and Contract Field changes:
- If ContractID is empty in the opportunity SObject, consider the ordertype as Contract - New.
- If ContractID is not empty, fetch all the details from the contract based on opportunity.ContractId
Select Id, StartDate, End_Date_For_Upsell__c,
Id =: opportunity.ContractId
- Based on the output, update these field values in the opportunity SObject.
- Check if the Current_Sales_Order_Id__c is empty and contractID is not null. This means the customer is trying to contract - upsell.
- So we set the order type as Contract - Upsell.
- OrderType and Contract Field changes:
- Changes for AccountField
- The account field is updated based on the “bill to tier” field.
- You can get the Account Field ID from the Sync with following Record setting in the Opportunity > Advanced settings.
- If the Bill to Tier is set as any of the following:
- Reseller: Then the re-seller value is updated based on the option selected in the "Sync with following Record" field.
- Distributor: Then the distributor value is updated on AccountId.
- End-user: Then the end-user value is updated on AccountId.
- Term calculation: The start date and end date must not be equals to empty to calculate the month's difference between these dates.
- Once you change the start date and the end date at the opportunity level, the Salesforce trigger checks if the opportunity line items are present or not. If present, the start date, and the end date are updated in the opportunity line items too.
Opportunity line item trigger
- Based on the custom settings, the Salesforce trigger checks if the contract renewal is enabled or disabled and accordingly it runs the appropriate flow.
- If the start date and end date are null, get the start date and end date from opportunity.
- Item Category on the Product is set to one of these:
- License - Term
- Maintenance - New
- Maintenance - Renewal
- Support - New
- Support - Renewal
Note: If the Item Category is not any of the above options, the calculations will not happen.
Validation Rules for the Start date and End date
You might see the following errors in your Salesforce account when you try to save the record:
- If the opportunity line item start date is less than the opportunity start date, the error message “Start date on line item should not be less than start date on the opportunity” is displayed.
- If the opportunity line item end date is greater than the opportunity end date, the error message “End date on line item should not be greater than end date on the opportunity” is displayed.
- If the opportunity line item start date is greater than the opportunity line item end date, the error message “End date should be greater than the start date” is displayed.
Based on the opportunity line item start date and opportunity line item end date will be calculated the terms.
- Fields used in the price calculations
- If netsuite_conn__Term_Contract_Pricing_Type__c is “Annual”
- Whatever the user enters the unit price will be stored in netsuite_conn__User_Entered_Sales_Price__c
- netsuite_conn__List_Rate__C will be calculated based on (netsuite_conn__User_Entered_Sales_Price__c/12)
- Above two steps will run only if oldopp_unitprice is not equal to newopp_unitprice
- Unit Price is calculated by: (netsuite_conn__List_Rate__C * netsuite_conn__Terms__c)
Please sign in to leave a comment.