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
kathybbkathybb 

No viable alternative at character '"'

I'm attempting to code a list and I have the above error showing up whenever i attempt to compile the class.  Can anyone spot what Is wrong and tell me how to fix it?

 

Here's my page:

<apex:page standardController="SFDC_Purchase_Order__c" extensions="AttachPRTOPOController" action="{!initList}">
    <apex:form >
        <apex:pageBlock tabStyle="SFDC_Purchase_Order__c" >
             <apex:pageBlockTable value="{!resultList}" var="r"
                        id="resultsBlock" columns="9" width="20%">
                    // rendered="{!NOT(ISNULL(resultList))}">
                        <apex:column headerValue="PR No." width="5%">
                            <apex:outputLink value="/{!r.id}?retURL={$currentPage.URL}">{!r.Name}</apex:outputLink>
                        </apex:column>
                        <apex:column value="{!r.status__c}"
                            headerValue="Status" width="5%" />"
                        <apex:column value="{!r.status__c}"
                            headerValue="Type" width="10%" />
                        <apex:column value="{!r.RecordType__c}"
                            headerValue="Item" width="5%" />
                        <apex:column value="{!r.Item_Requested__c}"
                            headerValue="new Item Description" width="15%" />
                        <apex:column value="{!r.New_Item_Description__c}"
                            headerValue="Quantity" width="15%" />
                        <apex:column value="{!r.Quantity__c}"
                            headerValue="Requested By" width="10%" />
                        <apex:column value="{!r.CreatedDate}" headerValue="Created On"
                            width="10%" />
                        <apex:column value="{!r.CreatedBy.name}" headerValue="Requested By"
                            width="15%" />
                    </apex:pageBlockTable>
                </apex:pageBlock>
            </apex:form>
</apex:page>

 and here is my class:

public with sharing class AttachPRTOPOController {
     
    private final SFDC_Purchase_Order__c myPO;
    public final string myUser = UserInfo.getUserID();
    public final PageReference myParentPage = ApexPages.currentPage();
    public List<tempPR> resultList {get;set;}
    public List<SFDC_Purchase_Requisition__c> castRequestList {get; set;}
   	public AttachPRTOPOController(ApexPages.StandardController con) {
        this.myPO = (SFDC_Purchase_Order__c)con.getRecord();
       }
   
    public PageReference initList(){
       
        if(resultList == null  || resultList.size()<1) {
            resultList = new List<tempPR>();
        }
        System.debug('*************************************************starting InitList resultList = ' + resultList.size());
            string inputVar = ApexPages.currentPage().getParameters().get('id');
            System.debug('*************************************************************************************************Inside initList now');
             string qry = 'SELECT id, Name, Department__c, Status__c,RecordType Request_Date__c,SFDC_Purchase_Requisition__r.Item_Requsted__c, New_Item_Description__c,' 
                 + 'Quantity__c from SFDC_Purchase_Requisition__c where Purchaser__c.id = :myUser order by name asc limit 200';
            castRequestList = Database.query(qry);
            System.debug('castAccountList = ' + castRequestList + 'size = ' + castRequestList.size());
           
            for(SFDC_Purchase_Requisition__c myPR :  castRequestList) {
                resultList.add(new tempPR(myPR));
                System.debug('**********************************************************************************Building castAccountList myPR = ' + myPR);
             }
        return null;
    }
    
    public List<tempPR> getRequests() {
        if(resultList == null) {
            System.debug('**********************************************************************************************Inside getAccounts resultList = null');
                initList();
        }else{
            resultList.clear();
         }
       System.debug('**************************************************************************************resultList returned from getAccounts' + resultList);
        return resultList;
    }

    public PageReference processSelected() {
        System.debug('****************************************************************************************************Entered processSelected');
        
        for(tempPR tPR : getRequests()) {
            if(tPR.selected) {
                system.debug('******************************************at selectedAccount constructed: ' + tPR);
                system.debug('******************************************resultList = ' + resultList);
                resultList.add(tPR);
            }
         }
        return null;
    }
           
       public class tempPR {
            public SFDC_Purchase_Requisition__c request {get; set;}
            public Boolean selected {get; set;}

        public tempPR() {
        }

        public tempPR(SFDC_Purchase_Requisition__c req1) {
            request = req1;
            selected = false;
            
        }
    }
    
}

 Since I'm not very experienced, I know there are probably other problems with my code, but this is the one I'm having no luck in solving on my own.  I've tried replacing the quotes in the <apex:page> code with single quotes (didn't work, of course, since visualforce requires the double  quotes) and using a plain text editor to insert double quotes (char 34) over the double quotes that are there. I would be very grateful for any help anyone can offer.

 

Thank you in advance,

kathybb

:

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
Line 1 Col 30 would be: standardController="... I wonder if that quote is somehow the wrong type of quote? Maybe you copied it from another program that uses a different quote character? Unfortunately, I don't see what else could be wrong, here. Try deleting your quote character and replacing it with a new one. Sometimes that helps, odd as it sounds.

All Answers

sfdcfoxsfdcfox

 

// rendered="{!NOT(ISNULL(resultList))}">

Should probably be:

 

<!-- // rendered="{!NOT(ISNULL(resultList))}"> -->

 Comments in Visualforce are always <!-- comment -->, not //.

 

 

kathybbkathybb

Thank you for telling me about this -- I'll write myself a note.  I made the correction to the comment, but it didn't solve the error message problem.  I appreciate the information -- I'm trying to get proficient in apex and I appreciate your help.

 

Kathybb

sfdcfoxsfdcfox

 

                        <apex:column value="{!r.status__c}"
                            headerValue="Status" width="5%" />"

That final quote (the one after />) is probably tripping up the compiler, then.

kathybbkathybb

You are centainly right that the quote at the end doesn't belong there, but I got rid of it and tried to save and I'm still getting  the same error message.  The error message clains that it's on Line 1 col 30, if that is any help.  I really appreciate the fact that you are taking time to help me!  Thank you very much.

 

KathyBB

sfdcfoxsfdcfox
Line 1 Col 30 would be: standardController="... I wonder if that quote is somehow the wrong type of quote? Maybe you copied it from another program that uses a different quote character? Unfortunately, I don't see what else could be wrong, here. Try deleting your quote character and replacing it with a new one. Sometimes that helps, odd as it sounds.
This was selected as the best answer
empucempuc

I think I found it.

 

I've even started to build Your data model to test it in practice but in the middle I found this one:

 

string qry = 'SELECT id, Name, Department__c, Status__c,RecordType Request_Date__c,SFDC_Purchase_Requisition__r.Item_Requsted__c, New_Item_Description__c,'

 

there is no comma after the RecordType field....

 

Please add it and let me know....  Im dying of curiosity!!! :)

kathybbkathybb

hi sfdcfox,

 

You were right, it was the quote characters that were messing with my mind.  I finally (grasping at straws) renamed my class and typed it in again in the Developement Environment.  By using the autocomplete for all my tags (which brings in quotes automatically) I finally got it to compile.  Thank you very, very much for your help!

 

Kathybb

kathybbkathybb

Hi, empuc,

I added the comma where it was missing, but it still didn't compile.  It turned out that something happened to the double-quote character that threw the compiler --  when I typed it all again into the development window and used the autocomplete to bring in the double-quotes, it compiled like a charm.  Thank you so much for your help -- I was going crazy.  I still don't know how the quotes (or a quotation mark) got corrupted, but at least I have a shot of diagnosing it if it happens again.

 

Thanks again,

 

kathybb

Amit desaiAmit desai
Here I am facing same issue i.e no viable alternative at character '"' in following code

if (INCLUDES(temp.Maths_Learning_Levels__c,"NR-0")) {
            m_nr0.put('Pre Test', m_nr0.get('Pre Test')+1);
          }
PhyoPinePhyoPine
The error is normally due to double quotes and single quotes confusion in the compiler. I have the same issue just now and after some hair-pulling time, resolved it by either making it all double-quotes or single-quotes for your String.

Hope this helps for anyone having the same issue.
sai sandeep chilakapatisai sandeep chilakapati
Hi friends,
No viable alternative at character '"'
I'm attempting to code a list and I have the above error showing up whenever i attempt to compile the class.  Can anyone spot what Is wrong and tell me how to fix it?
Please help me how to solve it..................!
Thank you.

trigger UpdateSalesRep on Account (Before insert,Before Update){
Set<Id> setAccOwner = new Set<Id>();
for(Account Acc: trigger.new)
{
setAccOwner.add(Acc.OwnerId);
}
Map<Id,User> User_map = new Map<Id,User>("select Name from User where id in:setAccOwner");
for(Account Acc: Trigger.new)
{
User usr=User_map.get(Acc.OwnerId);
Acc.sales_Rep__c=usr.Name;
}
}
Harry de WitHarry de Wit
Hi guys (and girls),
Facing the same issue, I found the following Dataloader solution:
....  where mydate = 2018-07-25

making sure the date is following the format YYYY-MM-DD (so simply add the zero before the month and/or day).

Cheers!
Kerri Leigh01Kerri Leigh01
I am receiving the same error. I have re-entered all the lines of code for both the VF and Apex class to make sure the correct quotation marks were being used. I also deleted any blank lines to make sure there were no special characters. I am still receiving this error:
line 1:45 no viable alternative at character '"' 
An unexpected error has occurred. Your development organization has been notified.

The log also shows a fatal error on line 5, column 1 of the class.

Can anyone assist? 

Here is the VF page:
<apex:page controller="NewCaseListController">
  <apex:pageBlock title="New Case List">
    <apex:repeat var="case" value="{!newCases}">
       <li>
        <apex:outputText value="{!case.ID}"></apex:outputText><br/>
        <apex:outputlink value="/{!case.ID}">{!case.CaseNumber}</apex:outputlink><br/>
       </li>
    </apex:repeat>
  </apex:pageBlock>
</apex:page>

Here is the Apex Class:
public class NewCaseListController {

public List<Case> getNewCases() {
    
    List<Case> newCases = Database.query(
        'SELECT ID, CaseNumber ' +
        'FROM Case ' +
        'WHERE Status="New" '
    );
    return newCases;
}
}
Kerri Leigh01Kerri Leigh01
I figured it out myself with some changes to the Apex class (see below):

public class NewCaseListController {

public List<Case> getNewCases() {
    string myStatus='New';
    List<Case> newCases = Database.query('SELECT ID, CaseNumber FROM Case WHERE Status=:myStatus');
    return newCases;
}
}