Updating Item External IDs in Bulk

Written by Jarad on September 18, 2023

The FastBound-UpdateExternals PowerShell script allows you to update external IDs for items on the FastBound platform using the FastBound API. This script processes a CSV file containing item data and sends PUT requests to the FastBound API to set external IDs. It can also generate external IDs if needed.

Prerequisites

Before you can use the script, you need to ensure you have the following prerequisites:

  1. PowerShell: This script requires PowerShell version 5.1 or later. To check your PowerShell version, open PowerShell and run the following command:

    $PSVersionTable.PSVersion

    If you don’t have PowerShell or have an older version, consider upgrading or installing it. You can download PowerShell from the official Microsoft website.

  2. Credentials:: You must have a FastBound account number and API key for authentication.

  3. CSV File: Prepare a CSV file containing item data. The CSV file must have columns for FastBound Item IDs (i.e., 00000000-0000-0000-0000-000000000000) and External IDs. By default, the script expects these columns to be named “Id” and “ExternalId,” but you can specify custom column names.

Script Usage

Here’s how to use the FastBound-UpdateExternals script with various options:

Generating External IDs

To generate external IDs for items in the CSV file and save them back to the file, use the following command:

.FastBound-UpdateExternals.ps1 -CsvFile "items.csv" -GenerateExternals

This command generates external IDs starting from the default value of 100 and assigns them to items in the CSV file. The updated CSV file will contain the generated external IDs.

Updating External IDs

To update external IDs for items on FastBound, use the following command:

.FastBound-UpdateExternals.ps1 -CsvFile "items.csv" -UpdateItems -AccountNumber <YourAccountNumber> -ApiKey "<YourApiKey>" -AuditUser user@example.com

  • Replace "items.csv" with the path to your CSV file containing item data.

  • Replace <YourAccountNumber> with your FastBound account number.

  • Replace <YourApiKey> with your FastBound API key.

  • Replace user@example.com with the email address of the user who is updating the items. This must be a valid FastBound user with access to the account.

This command will send PUT requests to FastBound to update the external IDs for items in the CSV file.

 

Updating and Generating External IDs

You can both update and generate external IDs in one command:

 

.FastBound-UpdateExternals.ps1 -CsvFile "items.csv" -GenerateExternals -UpdateItems -AccountNumber <YourAccountNumber> -ApiKey "<YourApiKey>" -AuditUser user@example.com

 

This command first generates external IDs for items in the CSV file and then sends PUT requests to FastBound to update the external IDs for items.

 

Custom Column Names

If your CSV file uses column names other than the defaults (“Id” for FastBound item IDs and “ExternalId” for external IDs), you can specify custom column names using the `-FastBoundIdColumnName` and `-ExternalIdColumnName` parameters.

 

.FastBound-UpdateExternals.ps1 -CsvFile "items.csv" -UpdateItems -FastBoundIdColumnName "CustomId" -ExternalIdColumnName "CustomExternalId" -AccountNumber <YourAccountNumber> -ApiKey "<YourApiKey>" -AuditUser user@example.com

 

Replace "CustomId" and "CustomExternalId" with your actual column names.

 

Usage Examples

To update external IDs for items using a FastBound account number and API key:

.FastBound-UpdateExternals.ps1 -CsvFile "items.csv" -UpdateItems -AccountNumber 12345 -ApiKey "your-api-key"

To generate external IDs and save them back to the CSV without updating on the server:

.FastBound-UpdateExternals.ps1 -CsvFile "items.csv" -GenerateExternals

To both generate and update external IDs on FastBound:

.FastBound-UpdateExternals.ps1 -CsvFile "items.csv" -GenerateExternals -UpdateItems -AccountNumber 123456 -ApiKey "your-api-key"

 

Additional Information

  • For more detailed information about the script and its parameters, run:
     
    .FastBound-UpdateExternals.ps1 -Help
     

  • The script automatically splits the data into chunks of 1000 items per API request (FastBound API limit).
     

Download PowerShell Script