Hi friends,
I have faced recently following pretty weird issue during batch job creation from AIF integration port.
AIF inbound endpoint gets XML message then process it and try to create Batch job:
protected void addBatchTask(int _secondDelay)
{
BatchHeader batchHeader;
SysRecurrenceData sysRecurrenceData;
BatchInfo localBatchInfo;
;
if (checkPostBatch)
{
batchHeader = batchHeader::construct();
sysRecurrenceData = SysRecurrence::defaultRecurrence();
sysRecurrenceData = SysRecurrence::setRecurrenceStartDateTime(sysRecurrenceData,
DateTimeUtil::addSeconds(DateTimeUtil::utcNow(), _secondDelay));
sysRecurrenceData = SysRecurrence::setRecurrenceEndAfter(sysRecurrenceData, 1);
localBatchInfo = checkPostBatch.batchInfo();
localBatchInfo.parmRetriesOnFailure(#NoOfRetriesOnFailure);
batchHeader.addTask(checkPostBatch);
batchHeader.parmRecurrenceData(sysRecurrenceData);
batchHeader.parmAlerts(NoYes::No, NoYes::Yes, NoYes::No, NoYes::Yes, NoYes::No);
batchHeader.save();
}
}
Then AIF exception appears:
DuplicateKeyException: Cannot create a record in Batch Job (BatchJob). Job description: MES goods issue processing task, Waiting.
The record already exists.
batchHeader.save() method tries to insert new BatchJob record but without success.
Looks very strange because BatchJob table has Primary key -> RecId field.
Then I just try to execute following Job:
static void MESBatchJobTest(Args _args)
{
batchJob batchJob;
;
ttsbegin;
batchJob.Status = BatchStatus::Waiting;
batchJob.OrigStartDateTime = dateTimeUtil::getSystemDateTime();
batchJob.Caption = "TEST MES goods issue processing task TEST";
batchJob.insert();
ttscommit;
}
and getting the same exception:
Does anyone encountered anything similar earlier?
Any suggestions are welcome!
*This post is locked for comments