Batch extensions are great for what they are intended to do, which is to add custom fields to batches. However, don’t think that they can be used for just that. You can also use batch extensions for what I’ll call a logical batch extension for import. The trick is to add a batch extension that doesn’t save data to a custom table. Here is a sample case I came across.
I need to import recurring gifts but I don’t have an end date but rather a duration and a start date as columns in the file. Let’s say the file export was set and that couldn’t be changed.
Write a batch extension with 1 field for the duration and mark it as hidden. Batch extensions require a base table so you will have to create a dummy one if you don’ have any physical fields in the extension already. Since the import process calls the batch add form, you really just need to code the add portion of the extension. Per the SDK requirement, you will have to fill in the parameters for the edit load, edit save and commit portion but they can just be empty procedures. Your add form however will have some code. Since the @ID coming in will be the batch row ID, you can used it to access the underlying batch table. In this case BATCHREVENUE. The product SP is called before the extension so there isn’t a concern of not having a record there. You can then fire and UPDATE statement against BATCHREVENUE to adjust the ENDDATE based on the start date plus your duration field. Of course you also want to check if the row is a recurring gift type and if duration is > 0 etc… Since the field is hidden, it will show in import but not in the batch window.
Using this technique, you can use extensions to fill small gaps like this that may come up with file based interfaces. Below is the SQL statement from the extension that was the basis of this article.
if @RCDURATION > 0 update dbo.BATCHREVENUE set INSTALLMENTENDDATE = dateadd(month, @RCDURATION, INSTALLMENTSTARTDATE) where ID = @ID and TYPECODE = 3 and INSTALLMENTENDDATE is null and INSTALLMENTSTARTDATE is not null UPDATE: A recent change to batch extensions for optimization purposes was made that could affect this technique. If the batch template does not contain any fields in the batch extension, it will not be executed. Therefore, you must make your field Required so that all batch templates include this field.