Hi,
I just modified the job to take AssetId and DepBookId as inputs. Test it and let me know.
static void AXC_ImportDepBooks(Args _args) { AssetDepBook assetDepBook; AssetTable assetTable; AssetDepBookTable assetDepBookTable; SysExcelApplication application; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; COMVariantType type; AssetId assetId; FileName filename; FileIOPermission permission; AssetDepreciationBookId assetDepBookId; int row = 1 ; #File application = SysExcelApplication::construct(); workbooks = application.workbooks(); filename = @"C:\\DepBookNames.xlsx"; permission = new FileIOPermission(fileName, #io_read); permission.assert(); try { workbooks.open(filename); } catch (Exception::Error) { throw error("File cannot be opened."); } workbook = workbooks.item(1); worksheets = workbook.worksheets(); worksheet = worksheets.itemFromNum(1);//.itemFromName("Sales target"); cells = worksheet.cells(); do { row++; assetId = cells.item(row, 1).value().bStr(); select assetTable where assetTable.AssetId == assetid; if (assetTable.RecId) { assetDepBookId = cells.item(row, 2).value().bStr(); assetDepBookTable = AssetDepBookTable::find(assetDepBookId); if (assetDepBookTable.RecId) { if (AssetDepBook::find(assetDepBookId, assetTable.AssetId).RecId) { info(strFmt("Depreciation bookId %1 is already connected with AssetId %2 at row %3", assetDepBookId, assetTable.AssetId, row)); } else { assetDepBook.AssetId = assetTable.AssetId; assetDepBook.DepreciationBookId = assetDepBookId; assetDepBook.DepreciationStartDate = today(); assetDepBook.insert(); } } else { info(strFmt("Depreciation bookId %1 is invalid or does not exist at row %2", assetDepBookId, row)); } } else { info(strFmt("Asset %1 is invalid or does not exist at row %2", assetid, row)); } type = cells.item(row+1, 1).value().variantType(); } while (type != COMVariantType::VT_EMPTY); application.quit(); CodeAccessPermission::revertAssert(); info("Operation completed"); }