Discount Logs

Available in Salesforce.

When calculating discounts, CT Orders creates logs that take up much space on the Salesforce side. Set up log storage on the Salesforce side to free up space.

For each Sales Organization:

  • In the Logging Mode field, select what type of logs to store, for example, only calculation logs. If you use the internal calculator, this is a single option to manage logs.

  • In the Log Request Trigger field, define when to request order logs from the Web Service: when saving the order cart or only when finalizing the order. This option is used when the Web Service is active for discount calculations. The user should have the CommercialCondition_Calculate custom permission.

You can schedule the Database.executeBatch(new Batch_CalculatorServiceLogDataSender()); batch to receive logs on a schedule.

Request and Receive Logs from Web Service

There are controlling fields on the required objects that are used in the logic:

  • The Log Id field of the Order, Order line Item,Delivery, and Delivery Line Item objects are responsible for the order structure and will be filled out once.

  • The value in the Log Status field of the Order object is automatically changed and displays the current order status, such as requesting or receiving logs.

Steps to receive logs in Salesforce:

  1. Salesforce sends a request to Web Service depending on the selected Log Request Trigger option or when the batch has started on the schedule.

  2. Salesforce changes the value in the Log Status field of the Order object from Not Requested to Requested.

  3. After receiving the request, the Web Service waits a bit for the logs to be generated on the server and then generates a .csv file based on the Log Ids.

  4. Web Service sends logs to Salesforce.

  5. Web Service changes the value of the Log Status field of the Order object from Requested to Received.

Logs are stored in the Calculated Discounts records.

Changing Log Ids deletes all Calculated Discounts records.
``