2

I want to build my own custom container, but I can't seem to get it working.

My Configuration: The DataCategoryGroup is called: Knowledge_Base The DataCategory is: testCategory I have 10 articles in Knowledge_Base:testCategory

My VisualForce Page with the standard container (see below) will show the list of 10 Articles:

<apex:page>
<apex:pageBlock title="My Searchresults">
    <knowledge:articleList articleVar="article" categories="Knowledge_Base:testCategory" hasMoreVar="false" pageSize="10">
        <apex:outputLink value="{!URLFOR($Action.KnowledgeArticle.View, article.id,['popup' = 'true'])}">{!article.title}</apex:outputLink><br/>
        <small>{!article.lastModifiedDate},{!article.Id}</small>
        <hr/>
    </knowledge:articleList>
</apex:pageBlock>

When I try to build it with a custom Apex Class and VisualForce Page (see below) it will not work.

APEX CLASS:

public class cc_debug_search {
public List<KnowledgeArticleVersion> getSearchResults(){ 
    String qryString = 'SELECT Id, title, UrlName, LastPublishedDate,LastModifiedById, KnowledgeArticleId FROM KnowledgeArticleVersion WHERE (PublishStatus = \'online\' and Language = \'en_US\')';
    List<KnowledgeArticleVersion> articleList= Database.query(qryString);
    return articleList;
}

}

VISUALFORCE PAGE:

<apex:page controller="cc_debug_search">
<apex:pageBlock title="My Custom Searchresults">
    <apex:repeat value="{!SearchResults}" var="article">
        <apex:outputLink value="{!URLFOR($Action.KnowledgeArticle.View, article.id,['popup' = 'true'])}">{!article.title}</apex:outputLink><br/>
        <small>{!article.lastModifiedDate},{!article.Id}</small>
        <hr/>
    </apex:repeat>
</apex:pageBlock>
</apex:page>

This will return the error message:

Unable to Access Page The value of a parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.

MY ANALYSIS:

It goos wrong on the {!URLFOR($Action.KnowledgeArticle.View, article.id,['popup' = 'true'])} part. It seems the returned Id is wrong. I also tried to replace it with:

  • {!URLFOR($Action.KnowledgeArticle.View, article.KnowledgeArticleId,['popup' = 'true'])}
  • {!URLFOR($Action.KnowledgeArticle.View, LEFT(article.Id,15),['popup' = 'true'])} to get a 15 char ID
  • {!URLFOR($Action.KnowledgeArticle.View, LEFT(article.KnowledgeArticleId,15),['popup' = 'true'])} to get a 15 char ID

All without result...

Can anyone help me with this?

1
  • Addition: I found out that if I use the article.KnowledgeArticleId (15 char version) and copy past it as String in the script below, it does work: {!URLFOR($Action.KnowledgeArticle.View, 'kA124000000TbBo',['popup' = 'true'])} But if I change it to this below, it doesn't work: {!URLFOR($Action.KnowledgeArticle.View, LEFT(article.KnowledgeArticleId,15),['popup' = 'true'])} <p>{!LEFT(article.KnowledgeArticleId,15)}</p> does return kA124000000TbBo – Wim May 11 '15 at 11:31
1

I've set up a similar environment and it seems to work for me with the first 15 characters of KnowledgeArticleId.

This is the controller method:

public List<KnowledgeArticleVersion> getSearchResults(){ 
    List<KnowledgeArticleVersion> articleList= [SELECT 
        Id, title, Summary, KnowledgeArticleId
        FROM KnowledgeArticleVersion 
        WHERE (PublishStatus = 'online' and Language = 'en_US')];

    return articleList;
}

And this is the repeat:

<apex:repeat value="{!SearchResults}" var="article" id="lstArticles">
    <div class="row">
        <div class="col-xs-8">
            <p class="knowledgebase_heading">
                <a href="{!URLFOR($Action.KnowledgeArticle.View, LEFT(article.KnowledgeArticleId,15))}" target="_blank">
                                    {!article.title}
                                    </a>
            </p>
            <p>{!article.summary}</p>
        </div>
    </div>
</apex:repeat>

Maybe the error has to do with something else, in my case, when adding more features I get a "too many SOQL queries" error. You can check it in the debug logs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.