Follow

API code example: Update accounts from CSV-file

Requirements

  • Visual Studio 2010 (any edition).
  • This is a command-line application and will run on any Windows.

Setup

A list of existing Visma Severa accounts is required for this code example as an input file. Such list can be created from Visma Severa:

  1. Click Browse on top menu.
  2. Select All accounts (or any other saved account report).
  3. Click on the CSV icon on top of the accounts list to save a CSV file of your account list.

Example CSV account list:

Account number;Account name;VAT number;Address;Postal code;Headquarters city;Account owner
1008;2nd Telecom Oy;;Mannerheimintie 12;00100;Helsinki;Flaming, Tony
1070;A Proctor Group Ltd;;The Haugh;;Blairgowrie;Stanley, Mark
1069;A Proctor Group UK Ltd;;The Haugh;;Blairgowrie;Stanley, Mark
1068;Aardvark Consulting;;;;;Riley, Nathan
1033;ACCESS TEST;;;;;Stanley, Mark
1021;Acme Oy;;Canon Street 123;lt 3454;London;Ashley, Lauren
1009;Acme Technology Inc.;;Street 12;90210;Beverly Hills;Stanley, Mark
1075;Aco Technologies Plc;;Aco Business Park;SG17 5TE;Bedfordshire;Stanley, Mark

 

Code

Download the source code zip package, which is as attachment in this article.

  1. Give the application two arguments: your API key, and the name of your account CSV file. The arguments can be found from the properties of the solution, from the Debug tab. Separate the arguments from each other with a space:

    update_accounts_-_arguments_for_application.png

  2. Put the account CSV file inside folder ...\Update accounts\bin\x64\Debug

  3. The program will iterate the given CSV file and make sure that the account's head office address will have the country of Finland (FI)

  4. Read 1 line from the file.

  5. Extract the unique account number with regular expression: System.Text.RegularExpressions.Regex.Match(line, "^([0-9]+);")

  6. Get the account information for the given account number.

  7. Get the internal company information from the account information.

  8. Get the head office address information from the company.

  9. Confirm that the address has country information, if does, next line.

  10. Set the address country to be the preloaded Finland country GUID.

  11. Update the address.

    Update accounts.zip

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Powered by Zendesk