You need to sign in to do that
Don't have an account?
Naveen 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;
}
}
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;
}
}
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.
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.....
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