> > |
This is where we define how each Appx field should be populated. The list of fields for the PROSPECT and CONTACT files is already populated for us because we clicked 'Populate Field Map' in the previous step. If we did not do that, we would have to manually add each field we are importing.
For each field in PROSPECT and CONTACT, we will choose the appropriate 'Source Type'. Not all fields are being populated from our source file, so for some fields, we leave the 'Source Type' blank. In this case, they will be assigned the default values as per the Data Dictionary.
The valid source types are:
- XML Data Field. When we choose this type, the XML Identifier, Application Id and Proces Name fields will become available for input. We can Scan on the XML Identifier field to choose an identifier that exists in the current XML file. The Application Id and Process Name allow us to specify a subroutine that we want to run when this field is imported (optional). The subroutine will be invoked DETACHED and will be passed 2 fields. You should RECEIVE 2 fields, the first field is the data extracted from the XML file and the second field is the XML identifier. You can change the first field, and the resulting data will be written to the Appx file.
- Parent APPX File. We use this when we want the Appx field to be filled in from another (Parent) Appx File. For example, when importing the Contacts, we want the CONTACT PROSPECT NO field to be filled in from PROSPECT NO. When we choose this type, the Application Id, Parent File Id and Parent File Field fields will become available for input.
- Sequence Number. Use this to automatically assign a sequential sequence number to the Appx field. Note that the sequence number starts at zero every time you run the import step, so normally you would not use this to generate unique keys in an existing Appx file that uses a sequence number key. However, in this example we will do that just to illustrate using the sequence number type.
- Date/Time Stamp. The current date/time will be set in the field.
Set up the Field mappings as follows:
Appx Field Namd |
Source Type |
Identifier or Parent App/File |
Notes |
PROSPECT NO |
Sequence Number |
|
|
PROSPECT COMPANY NAME |
XML Data Field |
/prospect/name |
|
PROSPECT DIVISION NAME |
Parent APPX File |
DMO/PROSPECT COMPANY NAME |
will automatically make Division name the same as Company Name |
PROSPECT ADDRESS 1 |
XML Data Field |
/prospect/add1 |
|
PROSPECT ADDRESS 2 |
XML Data Field |
/prospect/add2 |
|
PROSPECT CITY |
XML Data Field |
/prospect/city |
|
PROSPECT REGION |
XML Data Field |
/prospect/state |
|
PROSPECT POSTAL CODE |
XML Data Field |
/prospect/postal |
|
PROSPECT TELEPHONE |
XML Data Field |
/prospect/phone |
|
PROSPECT DATE ADDED |
Date/Time Stamp |
|
|
PROSPECT ADDED BY |
XML Data Field |
/prospect/phone |
We will use a subroutine to fill this field |
PROSPECT DATE CHANGED |
Date/Time Stamp |
|
|
PROSPECT CHANGED BY |
XML Data Field |
/prospect/phone |
We will use a subroutine to fill this field |
CONTACT PROSPECT NO |
Parent Appx File |
DMO/PROSPECT NO |
|
CONTACT LAST NAME |
XML Data Field |
/prospect/contact/lastname |
|
CONTACT FIRST NAME |
XML Data Field |
/prospect/contact/firstname |
|
CONTACT TITLE |
XML Data Field |
/prospect/contact/title |
|
CONTACT POSITION |
XML Data Field |
/prospect/contact/position |
|
|
|
|
|
Notice that we are mapping /prospect/phone to three fields. We don't really want the phone number stored in the ADDED BY/CHANGED by fields, we're just using it as a 'trigger' to run a subroutine that will fill in the correct data. Create a subroutine that contains the following lines:
RECEIVE --- TEMP 80 FIELD FAIL N
RECEIVE --- TEMP 79 FIELD FAIL N
SET --- TEMP 80 = --- USER ID
The first field received is the data extracted from the XML file, a phone number in this example. The second field is the XML Identifier. Since we are only running this subroutine to set the ADDED BY/CHANGED BY field, we do not need to test the XML Identifier or care about the incoming phone number. We can simply change the phone number to the current user id. When setting the PROSPECT ADDED BY / PROSPECT CHANGED BY fields, fill in the Application Id and Process Name of this subroutine. Another situation where you might need to use this technique would be to reformat incoming date/time fields.
Once you have filled in the data for all the fields, exit back to the main screen. We are now ready to save our definition, click the 'Store Map' button and you will be prompted for a name:
Fill in a name for this mapping and click 'Proceed'. The mapping will be saved.
Finally, we need to create the subroutine that does the work of importing the XML data into our Appx files. Click the 'Create Import Subr' button and you will be prompted for an Application Id and Process Name:
Fill in any Application and Process Name you want. When you click 'Proceed', the subroutine will be written and compiled. If any errors occur during the compile, you can view the subroutine in Application Design. You can also further customize the subroutine, however, you will lose those changes if you 'Create Import Subr' again.
Our mapping is now complete, press 'Exit' to return to the main menu. |