Salesforce

How Do I Create Dynamic Text Files? (Magic xpi 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Create Dynamic Text Files? (Magic xpi 3.x)

The Data Mapper service lets you map data from various sources into various types of text files. To map the data into the text file, you need to create a template file using Magic xpi merge tags that define the data elements. The Data Mapper service then uses these merge tags to map data from various Source types. This topic explains how to create dynamic text files in your project.

Note:

The template file can be in any format as long as the merge tags are stored as regular ASCII strings.

When you define a template file as the Destination in your Data Mapper service, the merge mechanism scans the template file for merge tags. The scanned tags are then displayed in the Data Mapper screen’s Destination section. You can map to these tags from any Source. For example, you can map XML or Database fields to the tags.

When you run your project, the tags are replaced by values according to the Source mapping that you defined.

Here are some sample Merge tags:

<!$MG_NAME> - this tag defines a tag name that is matched with a data element defined in the Data Mapper. You must replace NAME with a name for the tag. If a match is found when the Data Mapper scans the tag, the value replaces the tag.

<!$MGREPEAT> - this tag defines the beginning of a repeated area. The repeated area is duplicated and processed for each operation, thereby allowing for an unknown number of data rows. The tag is removed from the output.

<!$MGENDREPEAT> - this tag defines the end of a repeated area. The tag is removed from the output.

Example

This example describes how to transfer database table content to a text file. The first step is to create the template file and the second is to configure your Data Mapper service. Use the sample table below as an example.

Customer_ID

Order_ID

Product

Quantity

1

1

Chair

12

1

2

Table

12

Step 1: Creating the Template File

Create a text file with the following structure:

ID,Order_ID,Product,Quantity

-----------------------------

<!$MGREPEAT>

<!$MG_ID>,<!$MG_OrderID>,<!$MG_Product>,<!$MG_QTY>

<!$MGENDREPEAT>

Step 2: Configuring your Data Mapper Service

The steps below explain how to configure your Data Mapper Service:

  1. Drag the Data Mapper service to your flow and then click Configuration to open the Source/Destination Management window.

  2. In the Source area, click New, select Database as your Source type, and then click Properties to open the Database Schema Properties dialog box.

  3. From the DB Operation list box, choose Select and from the Database Definition List, select your database. Then click Wizard to open the Database Wizard.

  4. In the Select Table screen under Available tables, select your example table or any other table, click Add, and then click Next to open the Select the Columns screen.

  5. Click Add All to move the table’s columns to the Selected columns section and click b to open the Where Clause screen.

  6. Click Next to go to the Wizard Result screen and then click Finish to close the wizard and return to the Source/Destination Management dialog box.

  7. In the Destination area, select Template as your Destination type, and click Properties to open the Insert Destination Details screen.

  8. In the Template File field enter the location of the template file you created in Step 1.

  9. In the Data Destination list box select File, enter the file’s location, and then click OK.

  10. In the Source/Destination Management dialog box, click Map to open the Data Mapper screen.

  11. Map the table columns in the Source to the appropriate Destination.

  12. Click OK to close the Data Mapper screen and click OK to close the Source/Destination Management dialog box.

  13. Save and run the project.

Reference
Attachment 
Attachment