The following example creates Customer items from a CSV file:


  • The CSV file in the example resides in "c:\temp\customers.csv" and containers the following simplistic data:



  • The item is created in the default container "1000", however, this can be changed to any valid container.

  • The item must be checked out before modifying.

  • The Description field is an OverrideString which must be configured as Overridden.



Code Sample


# Read each line of the CSV.

$csvFilename = "c:\temp\customers.csv";

$csv = Import-Csv $csvFilename -Header @("Name","Description");

foreach ($line in $csv) {

    
    # Create the customer.

    Write-Host "Creating customer: $($line.Name)";

    $newItemID = $xia.DO_CreateItem($line.Name, "Customer", "1000");

    Write-Host "Created new item" $NewItemID;

    Write-Host "";

    

    # Set the item description.

    $xia.DO_CheckOutItem($newItemID);

    $newCustomer = $xia.GET_Customer($newItemID, 0);

    $newCustomer.Description.Overridden = "True";

    $newCustomer.Description.Value = $line.Description;

    $xia.SET_Customer($newCustomer);

    $xia.DO_CheckInItem($newItemID);


}   




Output