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
Naveen MadaanNaveen Madaan 

Getting error

i am geetting error in visual force when i am going to show my data in list and updating it.

public class contr {

  public View_attend__c acc{get;set;}  

 public view_attend__c getempl() {
    List<view_attend__c> my = newList<view_attend__c>();
    string st='';
    st = ApexPages.currentPage().getParameters().get('id');
    Listmy = [SELECT Login__c,status__c,Name_emp__C FROM view_attend__c where Name_emp__c =:st];
     if(my.isEmpty() == false){
      acc = my[0];
    else{
      ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'The Account ID is invalid.');
      ApexPages.addMessage(msg);
    }
   
        
        return acc;
    }

    public PageReference save() {
        update acc;
        return null;
    }
}
Vivek_PatelVivek_Patel
Hi Naveen,

Can you please paste the error here which you are getting? Also update Listmy to my, there is no Listmy variable in your class.

Regards,
Vivek Patel.

Please like or mark this as best answer if this answers your question to help others find better answer and improve the quality of developer forum.
Naveen MadaanNaveen Madaan
Thanks BRO...
yes i updated it already to my but still getting error , Acctually what is this term st = ApexPages.currentPage().getParameters().get('id'); &  actually does.
when i m doing it without any where clause it works but then i need  to mention indvidual URL id of every user and it works for one Name only whose id is specified . else it showing error??
System.QueryException: List has no rows for assignment to SObject at VF page  (if doing it without list type)
Class.contr.<init>: line 8, column 1
error is : contr Compile Error: unexpected token: '(' at line 6 column 53)  (if i am specifying as list type)
i dont know why.. i am new in salesforce plz help me out.....

 
Bhanu MaheshBhanu Mahesh
Hi Naveen,

Please provide space between new and List<view_attend__c>()
List<view_attend__c> my = new List<view_attend__c>();

This will resolve Unexpected Error.

Coming to 
st = ApexPages.currentPage().getParameters().get('id')

This will fetch the value of Id parameter from Url and assign that value too st variable.

For Ex: if your Url is /apex/pageName?id=001akelereAswed

Then your st value will be equal to 001akelereAswed

So ypu have to pass the variable Id in the url to get the records from view_attend__c otherwise the query will not return any records

Regards,
Bhanu Mahesh