4

When using the sfdx force:data:tree:export command, the Salesforce Developer Documentation states you can specify a file path in place of an in-line typed query (either option would follow the -q flag). I ran a simple query using the in-line version first :

sfdx:force:data:tree:export -q "SELECT Id FROM Account LIMIT 5" -d queries/accounts/ -u DevHub

And it created the json and path files without issue.

However, when I tried to swap out the in-line query for a file path directed at accountsquery.file which contains the exact same query string, I keep getting the following error:

➜  testProject sfdx force:data:tree:export -q queries/accountsquery -d queries/accounts/ -u DevHub

ERROR:  Invalid SOQL query: "select id from account".

Does the file need to be of a certain extension type? Is the syntax somehow different when you specify a file path? I'm not sure what I'm doing wrong, and I can't find an example of using the file path over an in-line string anywhere.

4

I just tried executing by create a simple file in a folder as shown in the below screenshot and below command worked fine

sfdx force:data:tree:export -q data/accounts/queryFile -d data/accounts/

My folder structure is as below and you can see i have a file shown in the editor

enter image description here

And you can see I have a file queryFile which does not have any extension .

The command line results are fine .

Looks like the file does not need to enclose query in double quotes and thats your issue .

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.