1

Can any one help me on this. I have a visual force page created in PDF format.
If the product line for the product selected in opportunity items is other than ‘ DIE’ make following changes .

1) unit price should change to $1.

Code :

if(OPplineitem[i].PricebookEntry.Product2.Product_Line__c=='DIE') 
                     {
                      tempObj.unitprice=0.01;
                      tempobj.extension=OPplineitem[i].Quantity * tempObj.unitprice;
                      tempObj.productname=OPplineitem[i].Bin_Item_Code__c;

                     }
                 else
                     {
                       tempObj.unitprice=$1;
                    // tempObj.unitprice=OPplineitem[i].ListPrice;
                     tempobj.extension=OPplineitem[i].Extension__c;
                    }

I get an Error as

 no viable alternative at character '$' at line 75 column 40

Any help is very much appreciated.

2
  • 1
    what is the datatype for this field(Unitprice) ? Mar 4, 2015 at 12:36
  • @ DKSalesforce Lerner:Datatype is :Currency for unitprice
    – nikkey
    Mar 4, 2015 at 15:56

1 Answer 1

0

unit price that you are using from priceBookEntry is basically a currency field. You dont need to append Dollar before that.

$ is automatically appended by salesforce based on the users locale.

You can just set it as 1 as internally Currency is also a number field. On the UI you can make use of inputField or output Field to display $ sign.

1
  • :The visual force page is in PDF format.It is a wrapper class.Previously the value for Unit price was hardcoded.Now <td class="header-table-data"><apex:outputtext value="{!line.unitprice}"></apex:outputtext></td>.Any help is very much appreciated.
    – nikkey
    Mar 4, 2015 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .