I decided to create a testcase and while doing so I found the problem to be related to my code.
Problem was the following (for me to recap and for you, if interested): The mailimport also needs to do string-to-ID conversion, client side BatchUpload does (Feature sponsorship from 2015). It does so via DataImport.importDataSourceRecords(). Here I'm using the correct DataSource that goes though DynamicDSGenerator (name V_LEADUPLOAD__someid__changedatesomeid). This fills my two fields as expected:
Code:
<field name="CUST_ADDRESS_COUNTRY_ID" importStrategy="display" uploadFieldName="ADDRESS_COUNTRY_ID" displayField="CUST_ADDRESS_COUNTRY_NAME"
foreignKey="T_COUNTRY.ID">
</field>
<!-- This includeFrom will be replaced in RegisterDS for imports with a profile. Be very careful when editing. Suffix COUNTRY_NAME is important -->
<field name="CUST_ADDRESS_COUNTRY_NAME" includeFrom="[B]T_COUNTRY.ISO_3166_1_ALPHA_2[/B]" />
DataImport fills field CUST_ADDRESS_COUNTRY_ID with the correct T_COUNTRY.ID and field CUST_ADDRESS_COUNTRY_NAME with the name it did the lookup for (e.g. "Germany").
Now when I do the ADD-operation with the correct data, I only used V_LEADUPLOAD. This has the problem that the includeFrom="T_COUNTRY.ISO_3166_1_ALPHA_2" is NOT replaced. But my name, it did the lookup for before (e.g. "Germany") is as data in the CUST_ADDRESS_COUNTRY_NAME field. And the field get an imported implicit length validator from T_COUNTRY.ISO_3166_1_ALPHA_2, making the ADD fail, because "Germany" is longer than 2 chars.
Another minor difference I noticed:
If the default includeFrom (here T_COUNTRY.ISO_3166_1_ALPHA_2) had canSave="false", no validator would be generated for the field with includeFrom and the ADD worked. I don't know if this is on purpose.
Gnerally I'd say that ALL includeFrom fields should be canSave="false" themselves (which I believe is already the case) and therefore do NOT need to import any validator from the field they link to.
Best regards
Blama
Leave a comment: