2

I have noticed that force CLI query returns the result in alphabetically for example if i will write query as force query select name,id from account then it will return the result as id then name. is anyone having any work around to solve this problem.

C:\Users\User>force query select name,ID from account limit 3
 Id                 | Name
--------------------+-----------------------------
 00128000002imxIAAQ | GenePoint
 00128000002imxJAAQ | United Oil & Gas, UK
 00128000002imxKAAQ | United Oil & Gas, Singapore
 (3 records)
4

This is a known issue as of now (acknowledged by Dave Carroll from Salesforce). I also see your comment on this thread. The workaround suggested to dump the output into CSV/ JSON and use external tool such as 'q' worked fine for me.

So, you should do something like this

force query select name,ID from account limit 3 > account.csv
q -H -d, 'select name, ID from account.csv'
| improve this answer | |
  • Hi we have tried this buts not working .. – ANITA SATPUTE Jul 27 '16 at 7:19
  • I tried and it seems to work for me. Which OS/ platform are you trying this on? – Gaurav Kheterpal Jul 27 '16 at 7:23
0

There are some limits piping "force query" output to "q" (like relative column names), but if you avoid the it can be handy.

I whipped together the following script which pipes "force query" through "q".

#!/bin/bash
if [ $# -lt 1 ]; then
    echo 1>&2 "usage: $0 soql-query"
    echo 1>&2 ""
    echo 1>&2 "does not handle dotted (relative) columns like 'owner.name'"
    exit 2
fi

#collect the SOQL satement into an environment variable
export SOQL=$@

#name a temporary file
export TMPFILE=soql.$$.csv

#execute "force query" and redirect to the temporary file
force query "$SOQL" --format:csv > $TMPFILE

#replace "from tablename" with "from temporary-file-name"
export QQL=`echo $SOQL | sed "s/from.*$/from $TMPFILE/g"`

#execute q with our new query
q -H -d, "$QQL"

#clean-up after ourselves
rm -f $TMPFILE
| improve this answer | |

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.