You need to sign in to do that
Don't have an account?
di_zou
Issue getting KnowledgeArticle data using Visualforce page and components
I have a Apex Class that looks like this:
global with sharing class Component_Query { global String queryString { get; set; } global List results { get { List result = Database.Query(queryString); return result; } set; } }
and a Apex Component that looks like this:
<apex:component controller="Component_Query" access="global"> <apex:attribute name="QueryString" type="String" required="true" access="global" assignTo="{!queryString}" description="A valid SOQL query in string form." /> <apex:variable value="{!results}" var="results"/> <apex:componentBody /> </apex:component>
My Visualforce page looks like this:
<apex:page > <apex:pageblock title="Recommended KB Articles"> <apex:outputPanel layout="block"> <ul> <apex:stylesheet value="{!URLFOR($Resource.custom_table_template)}"/> <table id="articles"> <th id="number">Article Number</th> <th id="title">Article Name</th> <th id="label">Article Type</th> <th id="date">Last Published Date</th> <th id="label">Article ID</th> <th id="label">Article ID</th> <th id="label">Parent ID</th> <knowledge:articleList articleVar="article" sortBy="mostViewed" pageSize="5"> <tr> <td>{!article.articlenumber}</td> <td><a target="_parent" href="{!URLFOR($Action.KnowledgeArticle.View, article.id)}">{!article.title}</a></td> <td>{!article.articletypelabel}</td> <td>{!article.lastpublisheddate}</td> <td>{!article.id}</td> <apex:variable var="articleid" value="{!article.id}"/> <td>{!articleid}</td> <td> <c:Query_component queryString="SELECT kavs.NormalizedScore, kavs.Id, kavs.ParentId FROM KnowledgeArticleViewStat kavs WHERE kavs.ParentId='{!articleid}'"> <apex:repeat value="{!results}" var="result"> {!result['ParentId']} </apex:repeat> </c:Query_component> </td> </tr> </knowledge:articleList> </table> </ul> </apex:outputPanel> </apex:pageBlock> </apex:page>
When I render my page in a browser, it looks like this:
How come my "Parent ID" column doesn't match up witht he KnowledgeArticle Ids? Is my foreign key incorrect or something? How do I get the KnowledgeArticleViewStat that is associated with the KnowledgeArticle?