Hi All,
I have a requirement to display a negative value with a dollar symbol and text functions but whenever I tried doing it am getting unexpected result.
For eg:
dollar(10000-30000,0) = "($20,000)" [but expected is "$20,000" an extra "(,)" is getting added due to negative symbol.
text(10000-30000,"0") = "2000-0" [but expected is "20000" an extra "-" is getting added due to negative symbol.
Do I need to pass anything specific format in the above functions to get the desired output?
Can someone please tell me what should be the format I need to use for the above scenario?
Regards,
Balaji.R
Discussion posts and replies are publicly visible
Hi , use below code 1)
stripwith( if( sign( 10000-30000 )<0 , append( "-", dollar( 10000-30000 ) ), dollar( 10000-30000 ) ), "()" )
result : "-$20,000.00"
2) dollar(abs(10000-30000)) result : "$20,000.00"
3)
text( 10000-30000, "###,###;-###,###")
result : "-20,000"
Hi rpbalaji2006 (balajir0001) there are multiple ways to achieve this requirement, hence please find the code snippet to achieve your requirement, mentioned below:
/* FOR dollar() related requirement */ /* Using Regex Pattern - using Appian Regular Expression Functions plugin */ regexreplaceall( "[()]", dollar(10000 - 30000, 0), "" ) /* OUTPUT: "$20,000" */ /* Achieving the same using String Manipulation - without plugin */ load( local!amount: dollar(10000 - 30000, 0), if( isnull(local!amount), dollar(0), replace( replace(local!amount, 1, 1, ""), len(replace(local!amount, 1, 1, "")), 1, "" ) ) ) /* OUTPUT: "$20,000" */ /* For text() requirement */ /* As you are already aware, when you subtract more amount from lesser one, you should expect negative value as it's result */ Approach 1: 10000-30000 /* OUTPUT: -20000 Type: Number (Integer) */ Approach 2: tostring(10000-30000) /* OUTPUT: "-20000" Type: Text */ /* You don't need to use text function to achieve this requirement, you can simply use one of the above approach depending upon what return type you are expecting */
Hope this will help you.
Hi Balaji,
I hope this code will help you.
rule!SPB_LMS_FL_textField(
label: "Balance",
isReadOnly: true(),
value:if(ri!exitBalance<0,
concat("-",pound(rule!returnPositiveDecimalNumber(ri!exitBalance))),pound(ri!exitBalance))
)
rule!returnPositiveDecimalNumber
-----------------------------------------------------------------------
if(
or(
rule!APN_isEmpty(
ri!decimalNumber
),
rule!checkIfDecimalNumberPositive(
ri!decimalNumber,
sqrt(
ri!decimalNumber * ri!decimalNumber
rule!checkIfDecimalNumberPositive
-----------------------------------------------------
ri!decimalNumber >= 0,
true(),
false()
Result
----------