Calculate Total Cost From Item Cost + Recurring Cost

Wasdom_Kung
Tera Guru
Hello,

 

I have a notification that when sent to a budget holder, contains information regarding the item being purchased. The item has a cost and a recurring cost has also been added, however I see that there isn't field option for total cost that would include both of these together.

 

Has anyone made a mail script or know a way to achieve adding a 'total cost' value to the notification?

 

Thanks!

1 ACCEPTED SOLUTION

VarunS
Kilo Sage

@Wasdom_Kung I am not 100% sure on the field names but below is an example.

Mail script example:

 

// Mail Script
(function() {
    var cost = current.cost; // Replace with the actual field name for the cost
    var recurringCost = current.recurring_cost; // Replace with the actual field name for the recurring cost
    var totalCost = (parseFloat(cost) + parseFloat(recurringCost)).toFixed(2);

    // Output the total cost
    template.print("Total Cost: $" + totalCost);
})();

 

 

In the notification, within the message body, include the mail script tag:

 

${mail_script:total_cost_script}

 

View solution in original post

2 REPLIES 2

VarunS
Kilo Sage

@Wasdom_Kung I am not 100% sure on the field names but below is an example.

Mail script example:

 

// Mail Script
(function() {
    var cost = current.cost; // Replace with the actual field name for the cost
    var recurringCost = current.recurring_cost; // Replace with the actual field name for the recurring cost
    var totalCost = (parseFloat(cost) + parseFloat(recurringCost)).toFixed(2);

    // Output the total cost
    template.print("Total Cost: $" + totalCost);
})();

 

 

In the notification, within the message body, include the mail script tag:

 

${mail_script:total_cost_script}

 

This worked, I was using the OOTB values so it would be recurring_price and price values, thanks!