Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Programmatically Adding Articles in Knowledge Base
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
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
Could you attach/post the NPE?
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™