Hide field on email notification if that field is empty in catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 05:48 AM - edited 08-14-2024 06:16 AM
Hi guys,
I have a requirement where catalog items have a price field, when this fields is filled in catalog item, then I would like to add this field to the approval email else I want this field to be hidden in approval mail.
I have created an email script to show this price field on email notification to the approver but I am not sure how to hide this field or cell value in email notification if price field is empty in catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 06:17 AM
That works only with fields that can be empty. Price fields always have a value. It can just be 0, but still the value is there.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 06:26 AM
Hi @Rajesh Chopade1 ,
I have to use this field on approval email i.e. on sysapproval_approver. Please check my email script and guide what changes needs to be done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 06:51 AM
try following script once, where I have taken care of price = 0 also - as suggested by Mark.
// Check if the recurring_price field is not null/empty and not equal to 0
if (current.sysapproval.recurring_price && current.sysapproval.recurring_price.getReferenceValue() != 0) {
// Calculate the total recurring price
var totalRecurringPrice = current.sysapproval.quantity * current.sysapproval.recurring_price.getReferenceValue();
// Format the total price
var formattedPrice = current.sysapproval.recurring_price.getReferenceCurrencyCode() + " " + parseFloat(totalRecurringPrice).toFixed(2);
// Print the formatted price to the email template
template.print("<p><strong>Price:</strong> " + formattedPrice + "</p>");
}