6. How to Create Reusable EDI Profiles

This section provides recommendations on how to configure xTuple Connect to send EDI. The example EDI Profile we created in Section 3.2, “Create a Simple EDI Profile” of Chapter 4, Basic EDI had significant limitations:

Then, in Section 1.2.2, “Defining New EDI Tokens”, we looked at ways to make EDI Profiles more flexible by finding and using document-specific information such as document numbers and appropriate email addresses in an EDI Profile.

Here are some suggestions on how to build a set of EDI Profiles that is flexible enough to do what you need without creating more EDI Profiles than you can manage.

6.1. Start Slowly

First of all, start with sending EDI to just one Customer or one Vendor. Pick one Document Type. Pick one file format. Don't try to set up xTuple Connect to send every document electronically to every business partner. Once you have one thing working, then you can expand your usage.

6.2. Start Generally

Think about your business partners. Which partners do you want to send documents to electronically? Who do you send the most Invoices or Purchase Orders to? How many of your partners should get their documents in the same format?

Pick as your starting Document Type the one that your biggest business partner or the largest number of your business partners want to receive as EDI. Pick as your file format the one your largest or the largest number of partners want to receive.

Now build and test an EDI Profile with a single EDI Form. As you go, try to replace anything specific to a single Customer or single document or single Document Type with an EDI token. Build your query to generate custom EDI tokens carefully. Think about where it might have problems:

  • Sales Reps who are not Employees might not have email addresses in the xTuple ERP database

  • The billing Contact for a Customer might not have an email address, so have a fall-back option such as the correspondence contact

  • The API Views might not have all of the data you need, so you might have to build more complicated queries using the regular xTuple ERP database tables

6.3. Grow Slowly

Once you have things set up for one Document Type, one file format, one business partner, decide where to expand next.

The safest thing to do is attach that same EDI Profile to other business partners first. This lets you test what you've done already to make sure it really is general and will work well.

Then add a second Document Type to that same EDI Profile, configure it with the same caution, and then expand usage to more business partners.

Over time you may learn that all you need is one EDI Profile with a couple of EDI Forms, all attached to all of your Customers.

As the business environment changes and your partners start to change their businesses, you may find that you need to build new EDI Profiles for particular partners. This is fine. As long as you started slowly and started generally, you should find that the number of EDI Profiles will stay relatively small and easy to manage.

6.4. An Example

You have decided to follow the recommendations above. The first EDI Profile you want to build will send Invoices by FTP to your Customers. Unlike email used in the previous examples, where there are contact records and user records with email addresses, there is no fixed place in the database to store FTP information. How do you build a general EDI Profile to send files to different FTP server for different Customers?

The example below creates and uses four EDI tokens that are not part of the standard set. It uses Customer Characteristics to hold the FTP hosts, user names, passwords, and directories. This approach has some security problems but will serve as an example of the kinds of thing you can do.

6.4.1. Building a General EDI Profile

  1. Follow this path: System > Master Information > EDI Profiles

  2. Click the NEW button

  3. In the "Name" field, enter "Sales_FTP_CSV"

  4. Leave the "EDI Type" set to "FTP"

  5. Check the "Review Before Sending" box

  6. In the "Server" field, enter </ftpserver>

  7. In the "Login Name" field, enter </ftplogin>

  8. In the "Password" field, enter </ftppassword>

  9. In the "Directory" field, enter </ftpdirectory>

  10. Create an EDI Form for Invoices

  11. In the "Query" field, enter the following text to retrieve the FTP connection information required to send an Invoice:

    SELECT (SELECT charass_value
            FROM charass JOIN char ON (charass_char_id=char_id)
            WHERE charass_target_type='C'
              AND charass_target_id=cust_id
              AND char_name = 'ftpserver') AS ftpserver,
           (SELECT charass_value
            FROM charass JOIN char ON (charass_char_id=char_id)
            WHERE charass_target_type='C'
              AND charass_target_id=cust_id
              AND char_name = 'ftplogin') AS ftplogin,
           (SELECT charass_value
            FROM charass JOIN char ON (charass_char_id=char_id)
            WHERE charass_target_type='C'
              AND charass_target_id=cust_id
              AND char_name = 'ftppassword') AS ftppassword,
           (SELECT charass_value
            FROM charass JOIN char ON (charass_char_id=char_id)
            WHERE charass_target_type='C'
              AND charass_target_id=cust_id
              AND char_name = 'ftpdirectory') AS ftpdirectory
    FROM invchead JOIN custinfo ON (invchead_cust_id=cust_id)
    WHERE (invchead_id=<? value("docid") ?>);
  12. Click SAVE to save the EDI Form

  13. Click SAVE to save the EDI Profile

One alternative to using Customer Characteristics, one that would address the security concerns, is to write a small xTuple Extension package with a table to hold the FTP data and associate these data with particular Customers. Then the server, login, and password information could be stored in encrypted form.

6.4.2. Entering the Required Customer Data

Now that we have a rather generic EDI Profile, we have to set up the Customers to use this Profile. There are several ways we can do this. We've chosen to store the FTP connection information in Customer Characteristics. To take this approach we must do the following:

  1. Create the Characteristics

  2. Define values for these characteristics for each Customer

  3. Attach the EDI Profile to each Customer for all three Document Types

6.4.2.1. Creating Customer Characteristics for FTP

If you read the query in the previous section, you'll know that it looks for four Characteristics associated with the Customer: ftpserver, ftplogin, ftppassword, and ftpdirectory. These do not yet exist in the database, so we have to add them:

  1. Follow this path: Sales > Master Information > Characteristics

  2. Click the NEW button

  3. In the "Name" field, enter "ftpserver"

  4. Check the "Customer" field

  5. In the "Description" field, enter "Used for EDI Profiles"

  6. Click the SAVE button

Repeat these steps to create the other three Characteristics that we need: "ftplogin", "ftppassword", and "ftpdirectory".

6.4.2.2. Defining Characteristic Values for each Customer

To send FTP to your Customers, you'll need to get the address for their FTP servers, either a host name (e.g., ftp.xtuple.com) or an IP address (e.g., 192.168.57.122), and a user name and password. You might also get a directory name in which to put the transferred files. In the example below, we'll use "localhost" for the FTP server, "xtedi" for the login and password, and the Customer Number for the directory.

The process to set up the Characteristics and enter values for each Customer depends on whether your Customers have a Customer Type that Enables Characteristics Profiles or not. For Customers who have Characteristics Profiles enabled, first follow these steps to add the Characteristics to the Characteristic Profile:

  1. Follow this path: Sales > Customer > Types

  2. Select a Customer Type with Enabled Characteristics Profiles (e.g. "NORMAL")

  3. Click the EDIT button

  4. Set the "Characteristic" field to "ftpserver"

  5. Click the Save button

  6. Repeat for "ftplogin", "ftppassword", and "ftpdirectory"

  7. Click the SAVE button on the Customer Type window

Next, set the individual Characteristic values for each Customer you want to send EDI to. Follow these steps to do so:

  1. Follow this path: Sales > Customer > List

  2. Select one of your Customers from the list that has the Customer Type you just edited (e.g. TTOYS)

  3. Click the EDIT button

  4. Click on the "Characteristics" tab

  5. Double-click on the "Value" column of the "ftpserver" row

  6. Type "localhost"

  7. Double-click on the "Value" column of the "ftplogin" row

  8. Type "xtedi"

  9. Double-click on the "Value" column of the "ftppassword" row

  10. Type "xtedi"

  11. Double-click on the "Value" column of the "ftpdirectory" row

  12. Type the Customer Number (e.g. "TTOYS")

  13. At this point, the Characteristics tab of the Customer window should look like this:

    Sample settings of Customer Characteristics for FTP EDI

Repeat this last set of steps for every Customer you want to set up to use the FTP EDI Profile just created. The process for adding Characteristics to a Customer without the Enable Characteristics Profiles limitation is much simpler. See the xTuple ERP Reference Guide for more information.

6.4.2.3. Attaching the EDI Profile to each Customer

The final configuration step is to attach the EDI Profile to each Customer. This ensures that the system finds the right EDI Profile and sends the right data in the right format whenever sending EDI for this Customer. Customers who do not have EDI Profiles defined will not receive any EDI (with the exception of Incident EDI if the CRM module is configured to send EDI for Incidents).

To attach the EDI Profile we created to a Customer, follow these steps:

  1. Follow this path: Sales > Customer > List

  2. Select one of the Customers you set the FTP Characteristics for from the list of Customers (e.g., TTOYS)

  3. Click on the "Transmission" tab

  4. Click the ATTACH button

  5. The "Attach EDI Profile" window will open

  6. Set the "Document Type" to "Invoice"

  7. Select "Sales_FTP_CSV" from the list

  8. Click the ATTACH button

  9. Repeat steps 4-8 for "Sales Order" and "Quote"

  10. Repeat steps 2-9 for another Customer

You're now done with your EDI configuration!

6.4.3. Testing

To test your EDI Profile, try sending an Invoice to one of the Customers you configured above:

  1. Follow this path: Accounting > Accounts Receivable > Invoice > Send Electronic Invoice

  2. Select the Invoice you want to send

  3. Review the information

  4. If you want to see what the document will look like when it is sent, click the PREVIEW button

  5. Click the ACCEPT button