• RGK.ax912
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 9
    Replies

Hi

 

I am really struggling trying to write the test class for this class, if anyone can help  or point me in the right direction it would be greatly appreciated.

 

Thanks

 

public class CaseArticleSfdcController{
    Case record;
    CaseArticle[] articles;
    String[] caseArticleIds;
    String fields;
    String caselanguage;
    Public String zzLang;
    Map<Id,List<FAQ__kav>> faqs;
   
    public Map<Id,List<FAQ__kav>> getFaqs(){
    zzLang=Caselanguage;
        if(faqs==null){
            if( hasArticles() ){
                String flds='';
                if( hasFields() ) flds=','+String.join(getFieldsArray(),',');
                String selectClause='SELECT Id'+flds+' ';
                String fromClause='FROM FAQ__kav ';
                String whereClause='WHERE Language = \'' + zzLang +'\' and IsVisibleInPkb= true and PublishStatus=\'Online\' and KnowledgeArticleId IN (\''+ String.join(getKnowledgeArticleIds(),'\',\'') +'\')';

//                String whereClause='WHERE Language = \'en_US\' and PublishStatus=\'Online\' and KnowledgeArticleId IN (\''+ String.join(getKnowledgeArticleIds(),'\',\'') +'\')';
               

                String qry=selectClause    +    fromClause    +    whereClause;
                Map<Id,List<FAQ__kav>> faqMap=new Map<Id,List<FAQ__kav>>();
                List<Faq__kav> results;
                system.debug('-----qry: '+qry);
                try{
                    results=database.query(qry);
                }catch(CaseArticleException e){
                   
                    ApexPages.addMessages(e);
                }
                if(results!=null){
                    for(Faq__kav f : results){
                        if(!faqMap.containsKey(f.KnowledgeArticleId)) faqMap.put(f.KnowledgeArticleId,new List<FAQ__kav>());
                        faqMap.get(f.KnowledgeArticleId).add(f);
                    }
                    faqs=faqMap;
                }
            } else ApexPages.addMessages(new CaseArticleException('Missing articles'));
        }
        return faqs;
    }
    public String[] getCaseArticleIds(){
        return caseArticleIds;
    }
    public void setCaseArticleIds(String[] s){
        caseArticleIds=s;
    }
    private List<String> getKnowledgeArticleIds(){
        if(    hasArticles()    ){
            List<String> ids=new List<String>();
            for(CaseArticle ca : getArticles())
                ids.add(ca.KnowledgeArticleId);
            return ids;
        } return null;
    }
    public Boolean hasArticles() {
        return getArticles()!=null;
    }
    public Case getRecord(){
        return record;
    }
    public void setRecord(Case c){
        record=c;
    }
    private CaseArticle[] getArticles(){
        if( articles==null ) {
            try{
                articles=[select id, KnowledgeArticleId,CaseId from CaseArticle where CaseId=:record.id];
            } catch(CaseArticleException e){
                ApexPages.addMessages(e);
            }
        }
        return articles;
    }
    private String[] getFieldsArray(){
        if(getFields()!=null)    return getFields().split(',');
        return null;
    }
    public Boolean hasFields(){
        return getFields()!=null;
    }
    public String getFields(){
        return fields;
    }
    public void setFields(String s){
        fields=s;
    }
   
    public String getCaseLanguage(){
        return caselanguage;
    }
    public void setCaseLanguage(String s){
        caselanguage=s;   
    }
    public class CaseArticleException extends Exception{}

  public static Boolean isRunningTest {
    set;
    get {
        if (isRunningTest == null) isRunningTest = false;
        return isRunningTest;
    }
  }   

I am trying to display the knowledge articles associated with a case in an email template.
The code I am using is:-

 

<messaging:emailTemplate subject="Test" recipientType="Contact" relatedToType="Case"> <messaging:plainTextEmailBody >

Hello {!recipient.name}-- This is the Article provided for your case Case Number: {!relatedTo.CaseNumber}-- Subject: {!relatedTo.Subject}--

<apex:repeat value="{!relatedTo.CaseArticles}" var="sol"> {!sol.KnowledgeArticle.ArticleNumber}  {!sol.KnowledgeArticle.Id}  {!sol.KnowledgeArticle.ArticleNumber}  {!sol.KnowledgeArticle.ArticleNumber}

</apex:repeat>

</messaging:plainTextEmailBody> 
</messaging:emailTemplate>

 

 

This works to a point in that it will display the details of hte Article Type__ka records for the associated Knowledge Articles, but I want to display the vlaues of the actal Article which are in the Article Type__kav object.
Is there any way to achieve this??
Thanks

I have installed this package and followed the instruction, but get the following error message:-

 

 The PKB Site Setup is not configured correctly. Please verify that the category group name is correct and that the group is active.

 

If I change line 345 of the Knowledge Controller to  siteName = 'Knowledge' (Knowledge is my site name) then I get past his error and get a partial resutl the layout is not very good, the search does not work, and if I add ?lang=de to the URL I still get English descriptions etc.

 

I think this means that my settings are correct, but that the controller is not picking up my site name automaticaly as this line is only triggered if the site name is null.

 

Has anyone any ideas how to resolve this issue?

 

Thanks

 


I would like to use a visualforce template to attache details of a knowledge article.

I have tried using the Articles as PDF field that works for Text and HTML emails, but this does not wotk.

Is there any way to do this??

Thanks

I have an apexinput field that displays a drop down selection box.

 

The problem is that if there an error validating the value entered the error message is not ver well presented on the page, all the message is printed below the field in a very narrow column.

 

Ideally I would like to display the error to the right of the input box.

 

The code for the input box is:-

 

 

 

             <apex:panelGrid columns="3" border="0" width="180" cellspacing="0" cellpadding="0" style="line-height:30px;text-align:right;font-weight:bold;font-size:8pt;padding-right:10px" rendered="{!(Case1.Web_Case_Reason__c!=null)}">
                    <apex:panelGrid columns="1" width="180" cellpadding="0" style="line-height:30px;text-align:right;font-weight:bold;font-size:8pt;padding-right:10px">
                        <apex:outputLabel value="{!$ObjectType.Case.fields.Type_Service__c.label}" for="cModel"/>
                     </apex:panelGrid>
                     <apex:outputPanel >
                        <apex:inputField value="{!Case1.Type_Service__c}" id="cModel" >
                             <apex:actionSupport event="onchange" rerender="theForm" status="status"/>
                        </apex:inputField>
                    </apex:outputPanel>
             </apex:panelGrid>

 Can anyone help me with this

 

Thanks in advance

 



Hi

 

I am really struggling trying to write the test class for this class, if anyone can help  or point me in the right direction it would be greatly appreciated.

 

Thanks

 

public class CaseArticleSfdcController{
    Case record;
    CaseArticle[] articles;
    String[] caseArticleIds;
    String fields;
    String caselanguage;
    Public String zzLang;
    Map<Id,List<FAQ__kav>> faqs;
   
    public Map<Id,List<FAQ__kav>> getFaqs(){
    zzLang=Caselanguage;
        if(faqs==null){
            if( hasArticles() ){
                String flds='';
                if( hasFields() ) flds=','+String.join(getFieldsArray(),',');
                String selectClause='SELECT Id'+flds+' ';
                String fromClause='FROM FAQ__kav ';
                String whereClause='WHERE Language = \'' + zzLang +'\' and IsVisibleInPkb= true and PublishStatus=\'Online\' and KnowledgeArticleId IN (\''+ String.join(getKnowledgeArticleIds(),'\',\'') +'\')';

//                String whereClause='WHERE Language = \'en_US\' and PublishStatus=\'Online\' and KnowledgeArticleId IN (\''+ String.join(getKnowledgeArticleIds(),'\',\'') +'\')';
               

                String qry=selectClause    +    fromClause    +    whereClause;
                Map<Id,List<FAQ__kav>> faqMap=new Map<Id,List<FAQ__kav>>();
                List<Faq__kav> results;
                system.debug('-----qry: '+qry);
                try{
                    results=database.query(qry);
                }catch(CaseArticleException e){
                   
                    ApexPages.addMessages(e);
                }
                if(results!=null){
                    for(Faq__kav f : results){
                        if(!faqMap.containsKey(f.KnowledgeArticleId)) faqMap.put(f.KnowledgeArticleId,new List<FAQ__kav>());
                        faqMap.get(f.KnowledgeArticleId).add(f);
                    }
                    faqs=faqMap;
                }
            } else ApexPages.addMessages(new CaseArticleException('Missing articles'));
        }
        return faqs;
    }
    public String[] getCaseArticleIds(){
        return caseArticleIds;
    }
    public void setCaseArticleIds(String[] s){
        caseArticleIds=s;
    }
    private List<String> getKnowledgeArticleIds(){
        if(    hasArticles()    ){
            List<String> ids=new List<String>();
            for(CaseArticle ca : getArticles())
                ids.add(ca.KnowledgeArticleId);
            return ids;
        } return null;
    }
    public Boolean hasArticles() {
        return getArticles()!=null;
    }
    public Case getRecord(){
        return record;
    }
    public void setRecord(Case c){
        record=c;
    }
    private CaseArticle[] getArticles(){
        if( articles==null ) {
            try{
                articles=[select id, KnowledgeArticleId,CaseId from CaseArticle where CaseId=:record.id];
            } catch(CaseArticleException e){
                ApexPages.addMessages(e);
            }
        }
        return articles;
    }
    private String[] getFieldsArray(){
        if(getFields()!=null)    return getFields().split(',');
        return null;
    }
    public Boolean hasFields(){
        return getFields()!=null;
    }
    public String getFields(){
        return fields;
    }
    public void setFields(String s){
        fields=s;
    }
   
    public String getCaseLanguage(){
        return caselanguage;
    }
    public void setCaseLanguage(String s){
        caselanguage=s;   
    }
    public class CaseArticleException extends Exception{}

  public static Boolean isRunningTest {
    set;
    get {
        if (isRunningTest == null) isRunningTest = false;
        return isRunningTest;
    }
  }   

I am trying to display the knowledge articles associated with a case in an email template.
The code I am using is:-

 

<messaging:emailTemplate subject="Test" recipientType="Contact" relatedToType="Case"> <messaging:plainTextEmailBody >

Hello {!recipient.name}-- This is the Article provided for your case Case Number: {!relatedTo.CaseNumber}-- Subject: {!relatedTo.Subject}--

<apex:repeat value="{!relatedTo.CaseArticles}" var="sol"> {!sol.KnowledgeArticle.ArticleNumber}  {!sol.KnowledgeArticle.Id}  {!sol.KnowledgeArticle.ArticleNumber}  {!sol.KnowledgeArticle.ArticleNumber}

</apex:repeat>

</messaging:plainTextEmailBody> 
</messaging:emailTemplate>

 

 

This works to a point in that it will display the details of hte Article Type__ka records for the associated Knowledge Articles, but I want to display the vlaues of the actal Article which are in the Article Type__kav object.
Is there any way to achieve this??
Thanks

Hello,

In my project we are using suggested articles (as a part of Service Cloud Console).

The question is : 

- Can the search for suggested articles by configured in any way ? For example, my client does not like, that he has to write full words in order for that to work (eg. when you type 'Salesfor' it will not find any Salesforce articles, but 'Salesforce' and 'Salesfor*' will find it). My client would like it to work as if the asterisk (*) was always there at the end of the subject

- Can we in any way customize what fields from the case should be used for search? As far as I notice currently only the Subject field is used.

- And the least important : can we customize the in any way the Suggested Articles columns? We would like to not have the 'New' column.

 

Knowledge looks promising for my client, but these are the limitations for now. I could probably somehow hack into the mechanism - in the HTTP requests i see what is going on and could probably mimic this behaviour with custom buttons and programming, but my client does not really want that.

 

Best regards

  • September 16, 2011
  • Like
  • 0

Hello,

 

I'm a visualforce newbie and I'm trying to create a visualforce email template that will include the content of the knowledge article because our support team needs to be able to edit some of the articles on the fly before they send the answer to the end user.  An example would be some customers use 'cart' and some use 'basket'.  Currently they are able to edit the solution in an email, but we lose that functionality with articles.

 

I've got the vf email template with the recipienttype=contact and the relatedToType=Case, but I'm stuck on how to relate to the article since {!relatedTo.articletype__kav} was not the answer.

 

Thanks so much for any insight!

  • September 01, 2011
  • Like
  • 0

Hi,

 

I'm trying to create a VF template for cases that will include the related Solution (from the Solutions related list on Cases).

 

I am getting an error: "Error: Invalid field Solution__r for SObject Case"

 

The code is as follows:

 

<messaging:emailTemplate subject="Test VF" recipientType="Contact" relatedToType="Case">
<messaging:htmlEmailBody>
<html>
<body>
<table border="0" >
<tr>

<th>Solution Detail</th>
<th>Solution Title</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Solution__r}">
<tr>

<td>{!cx.SolutionNote}</td>
<td>{!cx.SolutionName}</td>
</tr>
</apex:repeat>
</table>
<p/>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

 

Is what I want to do possible? And if so, can you help me with the error I am receiving.

 

Thanks!!

I have a VF page where i'm displaying articles from the articleList tag.  unfortunately the documentation doesn't tell me which fields are available for display.  i want to build the link manually, because using URLFOR appends retURL, which i don't want (in my case, it creates a mal-formed URL).  however it looks like i can't access the article.language field? 

 

so is there a way to access the language field, or is there a way to build the URL without getting retURL?

 

thanks

chris

Hi,

 

After attaching a Knowledge Article to a Case, I would like to know if there is a way to create an apex email template, which could access that article's data?

 

I've created the following working template:

 

 

<messaging:emailTemplate subject="Case Email Template" recipientType="User" relatedToType="Case">
<messaging:htmlEmailBody >
<p>Case Id: {!relatedTo.id},</p>
Congratulations! This is your new Visualforce Email Template. </messaging:htmlEmailBody> </messaging:emailTemplate>

 Is there a way to get to the Knowledge Article object fields from the relatedToType Case object?

 

Thanks!

  • February 04, 2011
  • Like
  • 0

We're building a custom integration with SF Knowledge where we need to use some, but not all of the Case functionality.  We like the Attach to Case stuff, but we don't like the Email as PDF stuff, so my plan was to upsert a solution for each Knowledge Article, and then insert an entry into the CaseSolution object for each one, so we could use the existing solutions merge field for the email templates (and also not have to update a couple dozen email templates while we're at it).

 

I don't see any accessible metadata in regards to querying, or even better, triggering on article attachment to Case.  Is there a way to get this info as of the Summer '10 release, or are we stuck in having to essentially build out an end to end custom solution for this type of integration?  I don't like going custom when it comes to page layouts, because Visualforce on a standard page layout is an ugly iframe implementation, which limits the functionality I can put in due to vertical space constraints (and my not wanting to waste vertical space).

 

Any insight would be appreciated.

Having trouble determining the right controller method for a search page for searching Solutions. I want to do a similar search function to the Find Solutions box that can be displayed in a homepage.

Code:
<apex:page controller="Solutions">
<apex:form>
<apex:pageBlock mode="edit" id="block">
<apex:pageBlockSection>
<apex:pageBlockSectionItem>
<apex:outputLabel for="searchSolutionText">Search Solutions</apex:outputLabel>
<apex:panelGroup>
<apex:inputText id="searchSolutionText" value="{!searchSolutionText}"/>
<apex:commandButton value="Go!" action="{!doSearch}"
rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="l"
rendered="{!NOT(ISNULL(results))}">
66
Controller Methods
<apex:column value="{!l.solutionname}"/>
<apex:column value="{!l.solutionnote}"/>
<apex:column value="{!l.createddate}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 
Code:
public class Solution {
String searchSolutionText;
List<Solution> results;
public String getSearchSolutionText() {
return searchSolutionText;
}
public void setSearchSolutionText(String s) {
searchSolutionText = s;
}
public List<Solution> getResults() {
return results;
}
public PageReference doSearch() {
results = (List<Solution>)[FIND :searchSolutionText RETURNING Solution(SolutionName, SolutionNote, CreatedDate)][0];
return null;
}
}

 I get a "Error: Compile Error: Incompatible types since an instance of LIST:SObject is never an instance of LIST:Solution at line 14 column 11" on the Apex Class.

Not sure how to proceed.




Message Edited by MATTYBME on 01-12-2009 06:05 AM