Hello,
I have to make a text 'Line Discount' appear on my printable only if the value of 'Line Discount' field is > 0.
Please suggest how to go about it.
Thanks
Like
Hello Madhuri,
This can be done with a custom macro. See https://customerfx.com/article/creating-custom-macros-to-format-values-…
Ryan
Hello Madhuri,
This can be done with a custom macro. See https://customerfx.com/article/creating-custom-macros-to-format-values-…
Ryan
Madhuri,
Please feel free to check the article in the Ryan's response.
On top of that, also check our the article on custom macros on our academy:
https://academy.creatio.com/docs/developer/elements_and_components/repo…
Best regards,
Yurii.
Hi Ryan / Yurii,
In my printable value is like this.
In Template:-
VAT: <<VatinPercentage>>
After print
VAT: 23.00
Now there are conditions where VAT can be 0, that time the label "VAT:" should not be visible and value '0' also should not be visible.
Is there any way to handle this that Entire "VAT: 0" should not be visible.
ramkiran kudipudi,
Yes, in the custom macro you'd pass in the VAT value. If the value is 0 the macro returns a blank string "". If the VAT value is not zero, it would return the string "VAT: " + vatValue.
The macro would look something like this:
namespace Terrasoft.Configuration
{
using System;
using Terrasoft.Common;
using Terrasoft.Core;
using Terrasoft.Core.DB;
using Terrasoft.Core.Entities;
using Terrasoft.Core.Packages;
using Terrasoft.Core.Factories;
using System.Globalization;
[ExpressionConverterAttribute("VAT")]
public class UsrVatConverter : IExpressionConverter
{
public string Evaluate(object value, string arguments = "")
{
// the value param would be the VAT field passed in
var vat = Convert.ToDecimal(value);
if (vat > 0)
return "VAT: " + vat.ToString();
else
return "";
}
}
}Then, to use the Macro, you'd add the VAT column to the report setup, then edit it by clicking the pencil icon on that row and add [#VAT#] at the end of it so it passes the value through the macro when the printable is generated.
Ryan