function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Swamy P R NSwamy P R N 

converting string to decimal for wrapper class variables

Hello folks,

In wrapper class defined one variable as Decimal, but unfortunately some times i have to show string in that variable. so for this i used
 Decimal.Valueof(string.Valueof('Product is not available for sale'))
but while running class and this method i'm getting followin error i.e, 
Invalid decimal: Product is not available for sale.

public List<CPQsubWrapper> shwoingPrices{get;set;}
public class CPQsubWrapper{
           public string couponCode{get;set;}
            public Decimal actualPrice{get;set;}
}
in method added logic like:
shwoingPrices.add(new CPQsubWrapper('abc', Decimal.Valueof(string.Valueof('Product is not available for sale'))));

So please suggest me where i need to change the particulat logic.

Thank you so much in advance!!
surasura

do not try to assing a strng to a decimal value , just assing a default value such as 0 and on your page check whether value is 0 and  if so then render your message else show the value . you can use the rendered attribute of visualforce page componenets to determine whether to show message or the value