Import Files Using Bulk API from Salesforce CLI

ย
You can now use the power of Bulk API to ๐ข๐ฆ๐ฉ๐จ๐ซ๐ญ ๐ ๐ฅ๐๐ซ๐ ๐ ๐ง๐ฎ๐ฆ๐๐๐ซ ๐จ๐ ๐ซ๐๐๐จ๐ซ๐๐ฌ ๐ข๐ง๐ญ๐จ ๐ ๐๐๐ฅ๐๐ฌ๐๐จ๐ซ๐๐ ๐จ๐๐ฃ๐๐๐ญ ๐๐ซ๐จ๐ฆ ๐ ๐๐จ๐ฆ๐ฆ๐-๐ฌ๐๐ฉ๐๐ซ๐๐ญ๐๐ ๐ฏ๐๐ฅ๐ฎ๐๐ฌ (๐๐๐) ๐๐ข๐ฅ๐ with the new data import bulk command ๐ช.
๐ข๐ข๐ข
Update sf cli to the latest version to use this(## 2.64.6 (October 30, 2024) [stable]).All the records on the csv file should be same Salesforce object
Use the --๐ด๐ฐ๐ฃ๐ซ๐ฆ๐ค๐ต
flag to specify the Salesforce object.
๐ด๐ง ๐ฅ๐ข๐ต๐ข ๐ช๐ฎ๐ฑ๐ฐ๐ณ๐ต ๐ฃ๐ถ๐ญ๐ฌ --๐ง๐ช๐ญ๐ฆ <๐ง๐ช๐ญ๐ฆ ๐ฏ๐ข๐ฎ๐ฆ> --๐ด๐ฐ๐ฃ๐ซ๐ฆ๐ค๐ต <๐ด๐ถ๐ฃ๐ซ๐ฆ๐ค๐ต ๐๐๐ ๐๐ข๐ฎ๐ฆ> --๐ธ๐ข๐ช๐ต <๐ธ๐ข๐ช๐ต ๐ต๐ช๐ฎ๐ฆ ๐ช๐ฏ ๐ฎ๐ช๐ฏ๐ถ๐ต๐ฆ๐ด> --๐ต๐ข๐ณ๐จ๐ฆ๐ต-๐ฐ๐ณ๐จ <๐ฐ๐ณ๐จ ๐ข๐ญ๐ช๐ข๐ด>
ย
๐For example,
Below command imports Account records from the **accounts.csv88 file into an org with alias “my-scratch”:
๐ด๐ง ๐ฅ๐ข๐ต๐ข ๐ช๐ฎ๐ฑ๐ฐ๐ณ๐ต ๐ฃ๐ถ๐ญ๐ฌ --๐ง๐ช๐ญ๐ฆ ๐ข๐ค๐ค๐ฐ๐ถ๐ฏ๐ต๐ด.๐ค๐ด๐ท --๐ด๐ฐ๐ฃ๐ซ๐ฆ๐ค๐ต ๐๐ค๐ค๐ฐ๐ถ๐ฏ๐ต --๐ธ๐ข๐ช๐ต 10 --๐ต๐ข๐ณ๐จ๐ฆ๐ต-๐ฐ๐ณ๐จ ๐ฎ๐บ-๐ด๐ค๐ณ๐ข๐ต๐ค๐ฉ
Thats All๐ช๐ช๐ช
SF CLI Takes care of the rest!๐งโจ
๐As Bulk imports takes time depending on how many records are in the CSV file the command time out after the specified wait time (10 minutes above).in this case it displays a job ID that you can pass to the new data import resume command to see the status and results of the original export.
๐ด๐ง ๐ฅ๐ข๐ต๐ข ๐ช๐ฎ๐ฑ๐ฐ๐ณ๐ต ๐ณ๐ฆ๐ด๐ถ๐ฎ๐ฆ --๐ซ๐ฐ๐ฃ-๐ช๐ฅ <๐๐ฐ๐ฃ ๐๐ฅ>
Resume the most recently run bulk import job for an org with alias my-scratch:
๐ด๐ง ๐ฅ๐ข๐ต๐ข ๐ช๐ฎ๐ฑ๐ฐ๐ณ๐ต ๐ณ๐ฆ๐ด๐ถ๐ฎ๐ฆ --๐ถ๐ด๐ฆ-๐ฎ๐ฐ๐ด๐ต-๐ณ๐ฆ๐ค๐ฆ๐ฏ๐ต --๐ต๐ข๐ณ๐จ๐ฆ๐ต-๐ฐ๐ณ๐จ ๐ฎ๐บ-๐ด๐ค๐ณ๐ข๐ต๐ค๐ฉ
๐Here is a quick demo on the same, the data is queried before and after running the command to verify the records are inserted.
watch demo video on linkedin
SF documentation on data import bulk SF documentation on Prepare Data to Ingest. That is creating csv file for data import.
This Content was originally posted in linkedin View Post