Issue with raiserror in batch

We are extending the Enhanced Revenue Batch but are running into issues when we attempt to throw our own errors in the commit → add section.

When the batch is initially committed everything seems to work fine and the validation report shows our errors but when you go into the exception batch only the last row has the error. I've confirmed the errors are not in the error message table either (except the last row).

If you fix the last row and try to commit the exception batch, the last row is handled correctly but then the new exceptions batch again only shows the error for the next last row.

Wondering if anyone has run into something like this before.

Our code is not overly complicated and mostly follows the examples from BB's batch type extension spec exercise. The weird thing is, pretty much the exact same code works when we extend the constituent update batch or when we use the same type of exception logic on our custom batches.

– Check if the constituent has a name request note

if (@IMPORT_CONSTITUENTID is not null)
begin
select top 1 ID
from CONSTITUENTNOTE
where CONSTITUENTID = @IMPORT_CONSTITUENTID
and CONSTITUENTNOTETYPECODEID = '451F41C0-1B27-44BC-B053-38A96A2974AA'

@ROWCOUNT > 0)

begin

-- This should happen the first time the end users commits
-- If name request exception is 0, meaning we want to throw this error for
-- rows where the constituent had a name request note that need manual review.
raiserror('Constituent has name request', 13, 1)
end

Original batch showing it has 2 errors after attempting the initial commit

1cbac5771e566886500f17d05b5c7233-huge-im

Exception batch only showing one error on the last row

abbbc27cfeb2b97a7287d72edeb9b2f4-huge-im

Comments

  • Hi John,

    Not something I can help with I'm afraid, but I was wondering if you had managed to work out a solution to this?

    Best,
    Will