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
paul-lmipaul-lmi 

Database Schema for SF Knowledge

Is there documenation on the default fields for the article objects that you can create for SF Knowledge?  I'd normally use the IDE to browse for what I need to identify, but v18 is delayed, and we've been given no ETA on it.

 

I'm trying to use SOSL in Apex to create a custom search engine for docs in Visualforce, and one of the things I want to respect is article visibility (internal vs. partner vs. public site).  If this is done via the CRUD permissions automatically based on the selection of those permission checkboxes when publishing, that's great, but if not, I'll need some insight as to what these field names are called in the database.

etienne_getienne_g

Paul,

you don't need to do the filtering by itslef, everything is based on the current user profile.

if you are running you API call with a customer portal user, then the query will return only articles available in the customer portal channel. 

Regarding the field names you can check the reference in the Spring'10 API documentation (http://wiki.developerforce.com/index.php/Documentation#API). Search for the standard object named KnowledgeArticleVersion.

 

Etienne 

paul-lmipaul-lmi

Hi Eitenne,

 

That didn't seem to be the case for me.  I wrote some Visualforce controllers to embed a "suggested articles" widget into the Case page.  When running it, the only way docs show up, is if all the permissions for the doc visibility are checked when it is published.  Is there some other permission set involved besides the "is knowledge user" on the user's record?

 

Also, another reason I was looking for the schema was to access stuff like the # of views/ranking and voting data to power some more creative widgets on our force.com implementation.

etienne_getienne_g

Paul,

 

First regarding the view and vote score / data: they are not yet accessible with the current release (spring'10). They should be exposed as of the next release.

 

Then for accessing article, a user needs to be a knowledge user and the user data category visibility settings needs to be compatible with the article categorization (for example if a user do not have access at all to one data category group, he will be able to access the article only if it is not categorized on this data category group)

paul-lmipaul-lmi

I'm access the article as a system admin, via Apex.  Unless I check all three channels for the visibility, the doc will not be returned via SOSL.

 

Here's the query that runs

 

/** * serchDocs does an SOSL query for documents based on provided params * Returns a search result list of lists of documents * @param keywords string representing teh search terms. These will be escaped. * @param productcode string product identifier, such as lmipro2 * @param langcode the lang code desired, such as 'en' or 'pt-br' * @param numresults the number of search results to return. capped at 100. * * each time a document type is added, add to the 'returning' part of the query, at the end */ Public Static List<List<sobject>> searchDocs(string keywords, string productcode, string langcode, integer numresults){ //make the search terms SOSL injection safe keywords = String.escapeSingleQuotes(keywords); //ensure categories are never null if(productcode == '' || productcode == NULL){productcode = 'AllProducts';} if(langcode == '' || langcode == NULL){langcode = 'en';} if(numresults > 100){numresults = 100;} /** cap the results at 100 for performance */ if(numresults < 1 || numresults == NULL){numresults = 5;} /** set a default of 5 */ //add the __c requried for custom data category names productcode = productcode + '__c'; langcode = langcode + '__c'; List<List<SObject>> qry = search.query('FIND \'' + '*' + keywords + '*' + '\'' + 'IN ALL FIELDs Returning FAQ__kav(ID, Title, Localized_Title__c, UrlName ' + 'WHERE PublishStatus = \'Online\') ' + 'WITH DATA CATEGORY Products__c AT ' + productcode + ' AND Language__c AT ' + langcode + ' LIMIT ' + numresults); system.debug('\n\nSearch results: ' + qry + '\n\n'); return qry; }

 

if it makes any difference, thsi is running in a sandbox at the moment.  I cannot get a doc to return in the SOSL result of this query unless all three channels are selected, even though it's being executed as the admin profile.  the page's controller, and the class that holds this static method, both use the "with sharing" declaration for the class.j  data categories do not seem to play a role in this issue, because visibility is gained without changing them at all, just the channel visibility options.