You need to sign in to do that
Don't have an account?
hiteshwar marni
Knowledge Articles
I'm querying some fields in knowledgearticle version , but I need to qeury another field from articletype__kav also.how to do it?
As there is no relation between knowledgeArticleversion and articletype__kav.
Thanks
As there is no relation between knowledgeArticleversion and articletype__kav.
Thanks
In the above image all the fields from knowledgearticleversion object are passed throught restapi.
But requirement is another field from howto__kav (description__c) object should also be sent
@RestResource(urlMapping='/mhcknw/*')
global class knowledgeApi{
@HttpGet
global static list<wrapperclass> findrecords(){
list<wrapperclass> wrapperlist;
RestRequest request = RestContext.request;
RestResponse res = RestContext.response;
string kmId = request.requestURI.substring(
request.requestURI.lastIndexOf('/')+1);
system.debug('######'+kmid);
list<KnowledgeArticleVersion> ka=[SELECT Id,KnowledgeArticleId,Language,PublishStatus,Summary,Title FROM KnowledgeArticleVersion WHERE PublishStatus = 'online' AND Language = 'en_US' and KnowledgeArticleId =:kmid];
system.debug('@@@@@@'+ka);
list<hitesh31__Test_Art__kav> htak= [SELECT ArticleNumber,ArticleType,Id,KnowledgeArticleId,Language,PublishStatus,Summary FROM hitesh31__Test_Art__kav WHERE Language = 'en_US' AND PublishStatus = 'online' AND KnowledgeArticleId =:kmid];
system.debug('*******'+htak);
for(KnowledgeArticleVersion ka1:ka){
for(hitesh31__Test_Art__kav htak1:htak){
wrapperlist.add(new wrapperclass(Ka1,htak1));
system.debug('&&&&&&&'+wrapperlist);
}
}
return wrapperlist;
}
global class wrapperclass{
public KnowledgeArticleVersion kversion;
public hitesh31__Test_Art__kav katype;
public wrapperclass(KnowledgeArticleVersion kn,hitesh31__Test_Art__kav k ){
kversion=kn;
katype=k;
}
}
}
In the above class i'm able to get records into the above two queries.but when i' calling this api from workbench it throwing nullpointer exception.I think there is some problem in wrapperlist.i'm not able to debug that, but records are getting into the query's.