Skip to content

Instantly share code, notes, and snippets.

View thebrettbarlow's full-sized avatar

Brett Barlow thebrettbarlow

View GitHub Profile
SELECT Id, Company, LeadSource, format(CreatedDate)
FROM Lead
ORDER BY CreatedDate
LIMIT 10
SELECT Id, FirstName, LastName, Title, Account.Name
FROM Contact
WHERE Title = 'CEO'
SELECT Id, Name, (SELECT Id, Name, Amount, CloseDate FROM Opportunities)
FROM Account
SELECT Id, Name, (SELECT Id, Name, Amount, CloseDate FROM Opportunities)
FROM Account
WHERE Id IN (SELECT AccountId FROM Opportunity)
# This will open a login page that will let you connect your org to the CLI
sfdx force:auth:web:login --setalias HelloWorldOrg
# You will now see the org you connected with!
sfdx force:org:list
soql "select id, username from user where firstname = 'chatty'" -u dev1
soql "
select id, name, ownerid, owner.name
from account
where ownerid = '005j000000Ea93uAAB'
" -u dev1 -r csv > chatty_accounts_to_move.csv
sfdx force:data:bulk:upsert \
--sobjecttype account \
--externalid id \
--csvfile chatty_accounts_to_move.csv \
--targetusername dev1 \
--wait 10
# query the accounts and put them in chatty_accounts_to_move__backup.csv
soql "
select id, name, ownerid, owner.name
from account
where ownerid = '005j000000Ea93uAAB'
" -u dev1 -r csv > chatty_accounts_to_move__backup.csv &&
# cut out the Id of each account and set the new OwnerId
cat chatty_accounts_to_move__backup.csv | \
cut -d "," -f 1 | \