You need to sign in to do that
Don't have an account?
apple_sae
List has no rows for assignment to SObject
Hi All,
I try to send the param from Visualforce page to my controller I just want to deleted my record from list
List has no rows for assignment to SObject
Error is in expression '{!removePayment}' in component <apex:page> in page welcomecustomerportal
An unexpected error has occurred. Your development organization has been notified.
My Visualforce Page:
<apex:repeat value="{!lstAuthContacts}" var="AC"> <apex:outputField value="{!AC.Name}"/> <apex:outputField value="{!AC.Contact_Type__c}"/> <apex:form> <apex:commandLink value="Remove" action="{!removeContact}"> <apex:param name="delContact" value="{!AC.Id}" assignTo="{!cParam}"></apex:param> </apex:commandLink> </apex:form>
My Controller:
public class AccountProfileController { public list<Contact> lstAuthContacts{get;set;} public AccountProfileController(){ getlstAuthContacts(); } public void getlstAuthContacts(){ lstAuthContacts = [Select Contact.Id, Contact.Name, Contact.Contact_Type__c, From Contact Where Contact.AccountId = ::ApexPages.currentPage().getParameters().get('id') And Contact.Contact_Type__c = 'Authorized Contact']; } public string cParam{get; set;} public PageReference removeContact(){ if(cParam != null || cParam != ''){ Contact contact = [select Id from Contact where id=:cParam]; delete contact; }else{ system.assertEquals('removeContact', 'ContactId = '+cParam); } return null; } }
It's work, my record is deleted but on visualforce is Show the error around 5 minute, after that I refresh agian it work agian
What going on?
Thank you vishal@forc
I have tired like your suggestion, but still not working .
but I founded solution I changed my controller to be like this:
Thank you for you help
All Answers
Your code looks fine except for this one condition check,
if(cParam != null || cParam != ''){
Make it - if(cParam != null && cParam != '')
Reason - If at all there's no parameter sent from the page, it can be blank or null and in either case you should not be querying. Rest all looks fine to me.
Thank you vishal@forc
I have tired like your suggestion, but still not working .
but I founded solution I changed my controller to be like this:
Thank you for you help
HI apple_sae
iam new one to apex and visualforce i tried your code but it showing error like
how this code solve please help me?
Hi, Sfdc@Smitha
Please shoe me your query, I'm not sure may be you for got to put a symbol like :
That's because there is an extra comma in there. Try changing the query to this: