Message Boards

Programmatically Adding Articles in Knowledge Base

thumbnail
Nirav Prajapati, modified 3 Years ago.

Programmatically Adding Articles in Knowledge Base

Regular Member Posts: 133 Join Date: 6/25/15 Recent Posts
Hello Friends,
I am using Liferay 7.2 SP1.
I am trying to add an article programmatically in the KB portlet. But's giving NPE while adding an article.

I have tried to add an article programmatically by following code and dependency which is working absolutely fine.

    compile group: 'com.liferay', name: 'com.liferay.knowledge.base.api'
    compile group: 'com.liferay', name: 'com.liferay.knowledge.base.service'
kbArticleService.addKBArticle(themeDisplay.getUserId(), 21303, 0, "Nirav Test KB Demo7", "nirav-test-kb-demo7", "<p>test demo 5</p>", "description", "", null, null, serviceContext);

Now,  According to the requirement I need to add the following dependency in build.gradle, which is generating another Option of Knowledge Base inside Site > Content & Data, and because of that my same above code is not working and throwing NPE.

 compileInclude group: 'com.liferay', name: 'com.liferay.knowledge.base.web'

Please help me to resolve the issue.

Thanks in Advance
thumbnail
Christoph Rabel, modified 3 Years ago.

RE: Programmatically Adding Articles in Knowledge Base

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
Could you attach/post the NPE?