I am trying to download a specific knowledge article version (standard - not lightning) using SFDX and powershell. My query gets dynamically generated in the script... and the relevent line of the script is as follows:

$query += " From $ArticleTypeAPIName WHERE publishstatus='$PublishStatus' AND language='en_US' AND urlname='the-article-urlname'"

However, when I run the query using sfdx like so:

sfdx force:data:tree:export -q $query -d $SaveToPath --targetusername $SourceOrgLabel

I get the following error:

ERROR:  The provided SOQL is malformed: Invalid language code. Check that the language is included in your Knowledge language settings.

Try this:
Check the SOQL syntax and try again.

If I simply dump the SOQL in $query to output, copy and paste it into the dev console it runs fine.

If I also remove the WHERE clause for the specific article AND remove the language argument, it works fine and gets all articles.

Why is sfdx having difficulties with this soql statement?


Try wrapping $query in quotes. eg:

sfdx force:data:tree:export -q "$query" -d $SaveToPath --targetusername $SourceOrgLabel

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.