I have created an agent that replicates data from a DB2 db on an AS\400 to a Notes DB. I tried following the best principles as shown in a webcast given on SearchDomino by Andre Guirard http://searchDomino.com/r/0,,11075,00.htm
To summarise my code:
Connect to DB2 (Source).
Connect to Notes (Destination).
Build SQL statement and Execute.
MapName Source and Destination LCFieldLists (since source and Destination "field" names are not the same).
Check Source Time Stamp against time agent last ran and Insert, Update to destination accordingly.
I have done some debugging and looped through both LCFieldLists, printed out values and all is well. The correct record set is returned, only the Source fields I require, MapName is working correctly.
But when I try to use :
"Call conLineItemNotes.Insert(destFldList, 1, 1)"
or Update it fails because it is trying to map my destFldList with the fields on the Destination Form, from top to bottom. For example, the top most field on the form is ComputedForDisplay "UNL" (MultiValue, Text) which it tries to map with the first LCField in the destFldList, which in this case is numeric.
If I understand correctly, the "Insert" will create a NotesDocument, creating fields supplied in the LCFieldList from: "Call conLineItemNotes.Insert(destFldList, 1, 1)" line.
I have bodged my way around this problem. I am creating\ getDocumentByKey in the destination DB, looping across the destFldList and creating NotesItem(s) onto the NotesDocument and saving. Aaarrgghh!!! If Andre Guirard is reading this I'm sure he is probably groaning.
All comments gladly welcomed,