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
Kristian HedeKristian Hede 

Public Knowledge Base 3 (PKB3) - Mobile Knowledge Articles Layout

Hi,

The main question is: How do we add custom article fields to the article detail page of the mobile version of Public Knowledge Base 3?

We are setting up a Public Knowledge Base at a client, which is the official Public Knowledge Base 3 (PKB3) from the AppExchange. We have enabled the mobile setup for PKB as well, which is working fine, except that it doesn't show custom article fields.

We have created a few Article types (FAQ, Guideline, etc.), which all have the Rich Text field called 'Cotent' (content__c). We want to display this field on the article detail page of the mobile layout, so we go to PKB 2 Settings | PKB Knowledge Article Layouts | Add Knowledge Article. We then choose one of the knowledge articles (i.e. Guideline__kav) and see the possible fields to add to the layout. All of the fields look like system information (i.e. Id, IsDeleted, CreatedById, etc.), which are pretty useless to an external customer reading the article. See screenshot below.

We looked at the code which loads the available fields which is quoted below. We have tried running the code as an administrator to rule out field level security of the article, which revealed the same fields as explained above.

A Public Knowledge Base, with a build-in mobile site which can only display system information on mobile article detail page seems a bit weird, so we are hoping we missed something, and that it is in fact possible to display custom article fields on a the mobile layout?
public static Object getKnowledgeTypesAndFields(String d){
          pkb_SecurityHandler.canAccess( new Schema.SObjectType[] {KnowledgeArticleVersion.sObjectType} );

            map<String,Object> ret = new map<String,Object>();
            String thisType = '';
            Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
            Set<String> keySet = gd.keySet();
            Schema.DescribeSObjectResult descRes;
            Map<String, Schema.SObjectField> fieldMap;
            for (String key : keySet) {
                Schema.SObjectType objectType = gd.get(key);
                if (key.endsWith('ka') || key.endsWith('kb')) {
                    descRes = objectType.getDescribe();
                    thisType = descRes.getName().replace('ka','kav');
                    fieldMap = descRes.fields.getMap();
                    ret.put(thisType,fieldMap.keySet());
                }
            }
          return ret;
    }
PKB Mobile Knowledge Articles Layouts

Thank you
Kristian
Best Answer chosen by Kristian Hede
Kristian HedeKristian Hede
So for anyone else facing the above issue, we solved it by changing the getKNowledgeTypesAndFields method to the method below. The changes being in lines 12 and 14:
 
public static Object getKnowledgeTypesAndFields(String d){
	pkb_SecurityHandler.canAccess( new Schema.SObjectType[] {KnowledgeArticleVersion.sObjectType} );

	map<String,Object> ret = new map<String,Object>();
	String thisType = '';
	Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
	Set<String> keySet = gd.keySet();
	Schema.DescribeSObjectResult descRes;
	Map<String, Schema.SObjectField> fieldMap;
	for (String key : keySet) {
		Schema.SObjectType objectType = gd.get(key);
		if (key.endsWith('kav') || key.endsWith('kb')) {
			descRes = objectType.getDescribe();
			thisType = descRes.getName().replace('kb','kav');
			fieldMap = descRes.fields.getMap();
			ret.put(thisType,fieldMap.keySet());
		}
	}
	return ret;
}

 

All Answers

Kristian HedeKristian Hede
So for anyone else facing the above issue, we solved it by changing the getKNowledgeTypesAndFields method to the method below. The changes being in lines 12 and 14:
 
public static Object getKnowledgeTypesAndFields(String d){
	pkb_SecurityHandler.canAccess( new Schema.SObjectType[] {KnowledgeArticleVersion.sObjectType} );

	map<String,Object> ret = new map<String,Object>();
	String thisType = '';
	Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
	Set<String> keySet = gd.keySet();
	Schema.DescribeSObjectResult descRes;
	Map<String, Schema.SObjectField> fieldMap;
	for (String key : keySet) {
		Schema.SObjectType objectType = gd.get(key);
		if (key.endsWith('kav') || key.endsWith('kb')) {
			descRes = objectType.getDescribe();
			thisType = descRes.getName().replace('kb','kav');
			fieldMap = descRes.fields.getMap();
			ret.put(thisType,fieldMap.keySet());
		}
	}
	return ret;
}

 
This was selected as the best answer
ThukkaramThukkaram
Hi,

I have changed the above code to display custom field in PKB3 mobile layout but still its throwing an error:
Cannot locate apex type for ID: 
ka2N00000008OQKIA2
class.pkb_mobile_controller.getpopulararticles: Line 307, column1
class.pkb_mobile_proxy.getremoteaction: line155, column 1
could you please suggest. Thanks!
 
ThukkaramThukkaram
Seems like the PKB3 is looking for the deleted article types as well.
Added the article type in query on pkb_mobile_controller(Method: pkb_mobile_proxy.ResponseItem getPopularArticles) and resolved the issue:
String KAVQ =   '   SELECT KnowledgeArticleId '+
                            '   FROM KnowledgeArticleVersion '+
                            '   WHERE PublishStatus =\''+pkb_Controller.DEFAULT_PUBLISH_STATUS +
                            '\' AND Language =\''+req.lang +'\'  and articletype= \'QA__kav\' '    //Thukkaram added article type to avoid issue
                            + qDC + ' LIMIT :maxKAVrecords ';
Thanks!
Brian Bellman 8Brian Bellman 8
This was very helpful and I got it to work in the sandbox, but I am having problems pushing the change to production. I am failing the Apex tests. How were you able to push these changes to production?
dddw ggdddw gg
Website Design in Ethiopia (https://shegertech.com" target="_self)
Nisha D 7Nisha D 7
Try this for mobile firmware: http://www.firmwarefilesearch.com

Samsung Firmware Download (http://www.firmwarefilesearch.com/samsung-firmware)
Vishal AswalVishal Aswal
Hi Everyone,Thank you for the this helpful article.
Here are Some Happy Birthaday Wishes for Everyone in English and in Hindi Check them out...
New Happy Bday Wishes in Hindi (https://happydiwalistatusmsg.blogspot.com/2020/04/happy-bday-wishes-status-in-hindibday.html)
Happy Mothers Day Status Wishes (https://happydiwalistatusmsg.blogspot.com/2020/04/happy-mothers-day-wishes-status-msg.html" target="_blank)
Happy Bday Wishes Quotes for Daughter (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for-daughter.html" target="_blank)
Happy Bday Wishes for Sister (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-for-sister.html" target="_blank)
Happy Bday Wishes for Girlfriend (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for.html" target="_blank)
Happy Birthday Wishes for Dad (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-father-dad.html" target="_blank)
Happy Birthday Wishes for Son (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for-son.html" target="_blank)
Happy Birthday Wishes for Boyfriend (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for-Boyfriend.html)
Happy Birthday Wishes for Best Friend (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for-bestfriend.html" target="_blank)
Funny Happy Birthday Wishes (https://happydiwalistatusmsg.blogspot.com/2019/11/funny-happy-birthday-wishes-quotes.html" target="_blank)
Happy Birthday Wishes for Mother (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for-mother.html" target="_blank)
Happy Birthday Wishes for Wife (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for-wife.html" target="_blank)
Happy Bday Wishes for Husband (https://happydiwalistatusmsg.blogspot.com/2019/11/happy-birthday-wishes-quotes-for-husband.html" target="_blank)
Birthday Wishes in Hindi (https://happydiwalistatusmsg.blogspot.com/2020/04/happy-bday-wishes-status-in-hindibday.html" target="_blank)
 
Rahman khan12Rahman khan12
Wow This is a great website for everyone, who wants to know latest update about sarkari naukari (https://motivatehindi.com/). 
Also You can check information lile Bhunaksha Bihar (https://motivatehindi.com/bhu-naksha-bihar/), Apna khata rajasthan (https://motivatehindi.com/apna-khata/)
Prashant Kumar 455Prashant Kumar 455
Nice Information, Thanks for sharing.
Universe Tale (https://www.universetale.com/)
Learn Forget (https://learnforget.com/)
Auto News Reporter (http://www.autonewsreporter.com/)
The Enumeration (https://www.theenumeration.com/)
Sagar PrasharSagar Prashar
Great Information. Thanks for sharing.
Softreview (https://Softreview.me)
Lyf Jio F220B Flash file download (https://www.softreview.me/2020/10/lyf-jio-f220b-flash-file-firmware.html
Anil vargheseAnil varghese
This was very helpful and solved the issues. Thanks for sharing the information. expect more updates on the topic in future. paymanager2 (https://indiaplus.in/paymanager-2/): 
Firmware DownloadFirmware Download
If you want to upgrade, downgrade, or reinstall the operating system on your smartphone, you need to download a flash file (https://firmwareflashfiles.com/). It can also resolve software issues, boot loop issues, IMEI issues, and dead issues.
Robert howard 5Robert howard 5
I’d have to check with you here. Which is not something I usually do! I enjoy reading a post that will make people think. Also, thanks for allowing me to comment!

http://traventure.blogolize.com http://traventure.blogolize.com http://traventure.blogolize.com
http://traventure.blogolize.com/
 
Anky KolaAnky Kola

Nimble information about mobile. Thanks.
best happy birthday (https://happy-birthday-images.com) pics.