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
Kon DeleKon Dele 

Knowledge Article System.QueryException: List has no rows for assignment to SObject

I'm getting the following error in a knowledge article controller that i'm working on:
Article__kav article1 = new Article__kav();
article1 = [select  URLName, id, Title,Partners__c,Cisco_Account__c, Article_Text__c,(select DataCategoryGroupName, DataCategoryName From DataCategorySelections) from Article__kav where publishstatus='Online' and Language = 'en_US' limit 1];
 system.debug(article1+'aaaaa+');
Any ideas on how I could edit this?
Best Answer chosen by Kon Dele
nitin sharmanitin sharma
I think you got to do somthing like :-

list<Article__kav> article1 = new list<Article__kav>();
article1=[select  URLName, id, Title,Partners__c,Cisco_Account__c, Article_Text__c,(select DataCategoryGroupName, DataCategoryName From DataCategorySelections) from Article__kav where publishstatus='Online' and Language = 'en_US' limit 1];
3
system.debug(article1+'aaaaa+');

All Answers

nitin sharmanitin sharma
I think you got to do somthing like :-

list<Article__kav> article1 = new list<Article__kav>();
article1=[select  URLName, id, Title,Partners__c,Cisco_Account__c, Article_Text__c,(select DataCategoryGroupName, DataCategoryName From DataCategorySelections) from Article__kav where publishstatus='Online' and Language = 'en_US' limit 1];
3
system.debug(article1+'aaaaa+');

This was selected as the best answer
Ramesh KallooriRamesh Kalloori
try to run the same query in developer console i think there is no records with the below query.

select  URLName, id, Title,Partners__c,Cisco_Account__c, Article_Text__c,(select DataCategoryGroupName, DataCategoryName From DataCategorySelections) from Article__kav where publishstatus='Online' and Language = 'en_US' limit 1

let me know if you have any questions.

thanks,
Ramesh