0
list<string> setknowledgeArticleIds = new list<string>();
setknowledgeArticleIds.addAll(knowledgeArticleIdToHS_Sync.keySet());

knowledgeQuery = 'SELECT Id ,KnowledgeArticleId ,  ' + title + ',' + answer + ' FROM ' + articleType;
        knowledgeQuery += ' WHERE PublishStatus = \'Online\'  AND language = \'en_US\' AND KnowledgeArticleId IN :setknowledgeArticleIds '; 

throwing an error : System.QueryException: Variable does not exist: setknowledgeArticleIds

In debug log i can see the query as :

SELECT Id ,KnowledgeArticleId ,  title,summary FROM hsinhouse__test_article_type_2__kav WHERE  PublishStatus = 'Online'  AND language = 'en_US' AND KnowledgeArticleId IN :setknowledgeArticleIds

Its a strange error . Please let me know if you find solution

Thanks

5
  • where are you running this query? Commented Nov 7, 2016 at 7:19
  • its is batch class and running batch class from developer console Commented Nov 7, 2016 at 7:22
  • 1
    found the issue . !! Sorry guys Commented Nov 7, 2016 at 7:30
  • what was the issue? Commented Nov 7, 2016 at 9:20
  • Scope of the variable was the issue . Query and all were correct . No issues in that Commented Nov 7, 2016 at 9:53

1 Answer 1

1

Is it a typo* that you typed aphostphe after the setknowledgeArticleIds variable in the last line, And Please let us know where are you trying to run this code.

If setknowledgeArticleIds is a list of ID's you can declare it as SET<ID> setknowledgeArticleIds instead of a List<String> setknowledgeArticleIds.

list<string> setknowledgeArticleIds = new list<string>();
setknowledgeArticleIds.addAll(knowledgeArticleIdToHS_Sync.keySet());

knowledgeQuery = 'SELECT Id ,KnowledgeArticleId ,  ' + title + ',' + answer + ' FROM ' + articleType;
knowledgeQuery += ' WHERE PublishStatus = \'Online\'  AND language = \'en_US\' AND KnowledgeArticleId IN :' + setknowledgeArticleIds;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .