• Jack Rose 1
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 10
    Replies
Hi, 

Really hoping someone is able to help me with an issue I'm having. I am a Salesforce Admin with no developer to hand. 
I am trying to do a change set to our Production Org, for a Apex Class. The purpose of the class is to insert the Data Categories into Custom Fields on the Knowledge Article. 
Unfortunately my change set failed as my test coverage was 0%. 

I have since discovered that I need a test class for the Apex Class but have no idea where to start. 
Here is the class I have, any help would be greatly appreciated. 
public class DataCategoryMgmtDL4B {
  @InvocableMethod
    public static void updateArticleTypeForDataCategories(List<Id> articleTypeIds)
    {
    
        List<string> DL4B_Products = new List<String>{'Property_Owner_Residential','Property_Owner_Commercial','Tradesman','Retail','Business_From_Home','Office_and_Surgery','Hotel','Pub_Restaurant','Tradesman_Professional','Property_Owner','Bed_Breakfast','Hair_Beauty','Office_Professional','Professional_Indemnity','Cyber','Van'};
        List<string> DL4B_Systems = new List<String>{'Acturis_ETrade','Evo','IS2000','PI_Legacy','SSP','UIS'};
        
        
        List<Knowledge__kav> lstArticleType = [SELECT Id, Title, DL4B_Data_Categories__c, DL4B_Systems_Categories__c FROM Knowledge__kav WHERE Id IN:articleTypeIds
                                                    AND PublishStatus = 'draft'];
        List<Knowledge__DataCategorySelection> lstDC = [SELECT ParentId, DataCategoryName FROM Knowledge__DataCategorySelection
                                                            WHERE ParentId IN:articleTypeIds];
        Map<Id, String> datacategoryNameMap = new Map<Id, String>();
        for(Knowledge__DataCategorySelection dcObj:lstDC)
        {
            if(datacategoryNameMap.containsKey(dcObj.ParentId))
            {
                String str =  datacategoryNameMap.get(dcObj.ParentId);
                datacategoryNameMap.put(dcObj.ParentId, str + ';' + dcObj.DataCategoryName);
            }
            else
            {
                datacategoryNameMap.put(dcObj.ParentId, dcObj.DataCategoryName);
            }
        }
        for(Knowledge__kav artObj:lstArticleType)
        {
            
            if(datacategoryNameMap.containsKey(artObj.Id))
            {   
                system.debug(datacategoryNameMap.get(artObj.Id));
                String allDataCategories = datacategoryNameMap.get(artObj.Id);
                List<String> parts = datacategoryNameMap.get(artObj.Id).split(';');
                artObj.DL4B_Data_Categories__c = '';
                artObj.DL4B_Systems_Categories__c = '';
                for(String unix: parts)
                {    
                    if(DL4B_Products.contains(unix)){
                        artObj.DL4B_Data_Categories__c += unix + ';';
                    }
                    if(DL4B_Systems.contains(unix)){
                        artObj.DL4B_Systems_Categories__c += unix + ';';
                    }
            }
        }
        update lstArticleType;
    }
}}

 
Hi All, 

Hoping someone can help me. I'm trying to add a static title to the browser tab for my community.Rather than the titl on the Tab displaying the name of the page tht is currently open, I want to force it to always say knowledge community, 
I've been trying to find some information on doing this and know I need to edit the community head mark up. I attempted to add the <Title> attribute but it did nothing (except stopping the page content from loading). 
I'm not a developer, just an Admin so any help would be appreciated. 

Thanks in Advance
Jack 
Hi All, 

Hoping you can help me as I'm not a developer. 

I've been told it's possible to trigger a mass update of lightning knowledge articles (we have circa 5000) using a Batch Apex. I want to trigger the update to invoke a process flow. How do I go about doing this?

Thanks in advance
Hi All, 

Looking for some help, I'm an Admin with no access to a developer. I am looking at creating an Apex Class to insert the data categories into a fields on knowledge articles. I have found the below details on how to achieve this. I'm unsure how I am able to do this with mapping a particular category group to a particular field, any suggestions?



In Salesforce, open the Developer Console (see Open the Developer Console).
Create a new Apex Class.
For this tutorial, you can name your class DataCategoryMgmt.
In your Apex Class, enter the following template:


public class DataCategoryMgmt {
  @InvocableMethod
    public static void updateArticleTypeForDataCategories(List<Id> articleTypeIds)
    {
        List<Knowledge__kav> lstArticleType = [SELECT Id, Title, Data_Categories__c FROM Knowledge__kav WHERE Id IN:articleTypeIds
                                                    AND PublishStatus = 'draft'];
 
        List<Knowledge__DataCategorySelection> lstDC = [SELECT ParentId, DataCategoryName   FROM Knowledge__DataCategorySelection
                                                            WHERE ParentId IN:articleTypeIds];
 
        Map<Id, String> datacategoryNameMap = new Map<Id, String>();
 
        for(Knowledge__DataCategorySelection dcObj:lstDC)
        {  
            if(datacategoryNameMap.containsKey(dcObj.ParentId))
            {
                String str =  datacategoryNameMap.get(dcObj.ParentId);
                datacategoryNameMap.put(dcObj.ParentId, str + ';' + dcObj.DataCategoryName);
            }
            else
            {
                datacategoryNameMap.put(dcObj.ParentId, dcObj.DataCategoryName);
            }
        }
 
        for(Knowledge__kav artObj:lstArticleType)
        {
            if(datacategoryNameMap.containsKey(artObj.Id))
            {
                artObj.Data_Categories__c = datacategoryNameMap.get(artObj.Id);
            }
        }
 
        update lstArticleType;
    }   
}


Adapt the template to your use case:
Change all six instances of Knowledge to the name of the article type you wish to modify.
Change both instances of Data_Categories__c to the API name of the field you have just created.
If you changed the name of your Apex class, remember to change DataCategoryMgmt to your new Apex class name.
Save your Apex Class.
Hi All, 

Hoping you can help. I need to make the data categories that are surfaced on our PKB mandatory. I have raised a case with Salesforce for help on this. They have informed me the "required" attribute can't be used and I need to;
  • Create a custom controller
  • The Controller should contain a boolean variable in it.
  • Set the boolean value to true if the data category has --no filter-- as the value
  • Check the value of the boolean variable on the component and display the error message accordingly, when trying to search. 

I need the above to be done per data catergory - preferably with custom error messages. 
Unfortunatley I'm not a developer, but I'm trying to learn more code. Could anyone point me in the right direction to get started. 

Thanks in advance 
Hi All, 

Hoping I can get some help with an issue I'm facing. I'm an admin but trying to learn some code. 
Our business requires the data categories surfaced on the PKB under the Search Narrow section to be mandatory before a user can search for an article. 

I had been told that the required="True" attribute needed to be added to the Outputpanel for each of the categories in the pkb_narrow VF page. However when saving I recieve an error stating that required is an unsupported attribute. 

Any suggestions would be much appreciated.
Thanks in advance 
Hi All, 

I have a VF page that is used by customers to upload documents to us, which create and attach themselves to a case. 
The name of the attachment is currently being set by the controller. 

I want the document name to include the value from a picklist on the page (Type_of_Document__c) however the the name is currently showing the field API name. 

Any thoughts on how to fix this?
insert objcase;
   
       System.debug('@@@@@objcase' +objcase);
        System.debug('@@@@@fileBody'+fileBody);     

        myAttachment  = new Attachment();

              Integer i=0;

              myAttachment.clear();

              myAttachment.Body = fileBody; 

              myAttachment.Name = 'Type_of_Document__c'+objcase.id+'.jpeg' ; 

              myAttachment.ParentId = objcase.id;             

              insert myAttachment;

 
Hi All, 

I am using a Force.com Site to host some forms for our customers, using multiple VF Pages. I have 2 Forms that are working fine. I have added a 3rd form (VF Page) to the site for uploading an attachment and creating a case. The Page loads correctly, but when clicking Save it displays an Authorisation Required error. 
When previewing the page on it's own, directly in SF rather than the site, the page works as expected. 

Any thoughts on what this could be?

Thanks in Advance
Hi, 

Is anyone aware if it is possible to use a visualforce page, a a web form, to create a case and upload a file to the case at the same time?
Hi All, 

I am new to developing so hope you all can help with an issue i'm having. I have been provided with some code by a developer that has now moved on. I have a visualforce page that uses bootstrap. The page is for the creation of cases. The page functions fine in Chrome, but not IE or firefox.
When using IE11, if a rerender is triggered, all previously captured data is removed and when submitting the form the data doesn't appear in the case (although one is created). 
When using Firefox, when submitting the form it clears all the captured data and doesn't submit the form. 

Any suggestions?
Hi All, 

I'm not a developer, so apologises if I'm asking a silly question.
I am looking into some code that has been provided to us, for a visual force page using Bootstrap. We have created a web form using visual force. 

When the Reason for change field is selected, it opens up a dynamic list of fields, along with a submit button that creates a case (providing no validation rules have been triggered. I have added the continue button below. I'm wanting to control the rendering of the reason field with the button, e.g. the field is only displayed once the button is clicked. 

I have started to attempt this in the code but keep hitting errors. any suggestions would be appreciated. User-added image
User-added image
Hi All, 

Hoping someone can help me. I'm trying to add a static title to the browser tab for my community.Rather than the titl on the Tab displaying the name of the page tht is currently open, I want to force it to always say knowledge community, 
I've been trying to find some information on doing this and know I need to edit the community head mark up. I attempted to add the <Title> attribute but it did nothing (except stopping the page content from loading). 
I'm not a developer, just an Admin so any help would be appreciated. 

Thanks in Advance
Jack 
Hi, 

Is anyone aware if it is possible to use a visualforce page, a a web form, to create a case and upload a file to the case at the same time?
Hi All, 

I'm not a developer, so apologises if I'm asking a silly question.
I am looking into some code that has been provided to us, for a visual force page using Bootstrap. We have created a web form using visual force. 

When the Reason for change field is selected, it opens up a dynamic list of fields, along with a submit button that creates a case (providing no validation rules have been triggered. I have added the continue button below. I'm wanting to control the rendering of the reason field with the button, e.g. the field is only displayed once the button is clicked. 

I have started to attempt this in the code but keep hitting errors. any suggestions would be appreciated. User-added image
User-added image