0

I want to fetch KB Articles which are "Submitted for Approval". In PublishStatus - We only have two values - Draft and Published.

How to query articles which are in Draft and Submitted to Approval(These are displayed with lock Symbol).

SELECT PublishStatus FROM KnowledgeBase__kav 

The above query doesn't return the status which explains that article is submitted for approvals.

1
  • Hi, welcome to SFSE, please refrain from asking for help and mentioning thanks in your posts, it is not useful. Thanks!
    – glls
    Oct 21 '17 at 15:28
0

By default, only online articles will be queried alongside your default language in knowledge settings.

That being said, your current SOQL will only display online.

First you will need to query for the Id's of the draft articles. (I encourage you to check the documentation for the sObjects to know what fields you can query on at Salesforce Knowledge Developer Guide )

Then, to be able to query for articles that are currently going through an approval process you will need to fetch a list of ID' currently in draft and then query ProcessInstance IN list of ID's of your draft articles

you will then have a list of draft articles going through an approval process (if any)

you can check this post for checking for records going through an approval process.

example query:

SELECT Id, TargetObjectIdFROM ProcessInstance 
                                        WHERE TargetObjectId IN :recordIds
3
  • I tried this query in my developer console, just to get the Ids from ProcessInstance. This is not working for me. Select Id From ProcessInstance WHERE TargetObjectId =:'01I0S0000002Xmq' Here 01I0S0000002Xmq being my Knowledge Object ID. I am getting error: Unknown error parsing query Oct 21 '17 at 17:44
  • I invite you to go through the following guide: Introduction to SOQL and SOSL
    – glls
    Oct 21 '17 at 17:48
  • the colon is unnecessary for your current context and test query
    – glls
    Oct 21 '17 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.