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
ndotlndotl 

Id value null is not valid for the FAQ__kav standard controller

I was able to make use of the <knowledge:articleList> tag using a custom controler. I found that  the <knowledge:articleRendererToolBar> was not functional and documentation suggests it requires FAQ__kav as the standard controller. So I made the custom controller an extension as follows:

 

public class pkbController {  

 public FAQ__kav pkbRecord{get;set;}

   public pkbController () { 

      String kid = System.currentPagereference().getParameters().get('kid');

      if(kid != null) { 
         pkbRecord = [SELECT id, Summary, Title, KnowledgeArticleId, id, PublishStatus FROM FAQ__kav
                               WHERE    PublishStatus = 'Online' AND KnowledgeArticleId = :kid];
   }
 } 

 public pkbController(ApexPages.standardController std) {
   this.pkbRecord = (FAQ__kav) std.getRecord();
 } 
...
}

 

 

 

In the associated page I changed this:

     <apex:page controller="pkbController" ...

to this:

 

     <apex:page standardController="FAQ__kav" extensions="pkbController" ....

 

 

In doing so, when the page now first displays an error page displays with the following message:

 

   Id value null is not valid for the FAQ__kav standard controller

 

The variable Id is not referenced on the page. However, I found that when I appended "&Id=xyz" to the URL parameters where xyz is a valid Article Id, the page displays as it did previously, with the list of Articles retrieved during the keyword search. The problem is, when the page is first displayed there cannot be a valid ID available because that is generated when the user makes a selection from the <knowledge:articleList > list. Also, prior to implementing the extensions change, the Id of the selected article is contained in a URL parameter named "kid". 

 

Can someone explain:

 

1) Is FAQ__kav really needed as the standard controlller when using the <knowledge:articleRendererToolBar> tag? If now, would you know why the knowledge:articleRendererToolBar failed to function when fed a valid ID? 

 

2) Is there an obvious flaw in the extenstions setup? I assume this is so because when the page is first displayed there is no way an Article Id could be available since one has not been selected from the list of Articles.

 

Thanks in advance.

 

David

 

 

 

francoisLfrancoisL

Hi, 

 

here an example of VF article template that is working:

 

<apex:page standardController="Troubeshooting__kav" sidebar="false" showHeader="{!!isPopup}" extensions="ArticleExtension" standardStylesheets="true">
    
    <style>
        body {
           background: #fff url(/img/alohaSkin/lookup_bg.png) repeat-x;
        }
    </style>
    <apex:outputField value="{!Troubeshooting__kav.PublishStatus}"  rendered="false" />
    <apex:outputField value="{!Troubeshooting__kav.KnowledgeArticleId}"  rendered="false" />

    <div class="hasMotif knowledgeTab popup tabArticleRenderer">
    <knowledge:articleCaseToolbar articleId="{!kaID}" caseId="{!caseID}" rendered="{!IF(caseID != null, true, false)}"></knowledge:articleCaseToolbar>

 

And my controller extension:

public class ArticleExtension {
    
    public List<CaseArticle> casesAttached {get; set;}
    public string                      caseID {get; set;}
    public string                      kaID {get; set;}
    public boolean                     isPopup {get; set;}
    public Troubeshooting__kav         articleVersion {get; set;}
    public string                      editArticleUrl {get; set;}
    public integer                     numOfCreatedArticles  {get; set;}
    
    public ArticleExtension(ApexPages.KnowledgeArticleVersionStandardController controller) {
        articleVersion = (Troubeshooting__kav) controller.getRecord();
        
        kaID = articleVersion.KnowledgeArticleid;
        
        caseID = ApexPages.currentPage().getParameters().get('caseid');
        
        if (ApexPages.currentPage().getParameters().get('popup') != null &&
            ApexPages.currentPage().getParameters().get('popup').equals('true'))
            isPopup = true;
        else isPopup = false;
        
        casesAttached = getCaseArticles();
        editArticleUrl = buildArticleEditUrl();
        numOfCreatedArticles = getNumOfCreatedArticleByAuthor();
    }