Axapta 根据人员编号更新HCMWorker RecId字段
我收到了一个CSV文件,该文件为我提供了SalesQuotationId和人员编号,我创建了一个作业,通过Axapta 根据人员编号更新HCMWorker RecId字段,axapta,dynamics-ax-2012,x++,Axapta,Dynamics Ax 2012,X++,我收到了一个CSV文件,该文件为我提供了SalesQuotationId和人员编号,我创建了一个作业,通过find方法查找SalesQuote 在SalesQuotationTable上,我有一个字段,与HCMWorker的RecId一起存储。问题是,我只有CSV文件中的人员编号。我找不到如何根据人员编号更改HCM工作人员的RecId static void UpdateHCMWorkerField(Args _args) { #File CommaTextIo
find
方法查找SalesQuote
在SalesQuotationTable上,我有一个字段,与HCMWorker
的RecId
一起存储。问题是,我只有CSV文件中的人员编号。我找不到如何根据人员编号更改HCM工作人员的RecId
static void UpdateHCMWorkerField(Args _args)
{
#File
CommaTextIo inFile;
Container con;
int i;
FileIOPermission permission;
FilePath readFile;
SalesQuotationTable salesQuotationTable;
SalesQuotationId quotationId;
str worker;
HcmWorker hcmWorker;
;
readFile = "File.csv";
permission = new FileIOPermission(readFile, #io_read);
permission.assert();
inFile = new CommaTextIo(readFile, #io_read);
inFile.inFieldDelimiter(",");
while (inFile.status() == IO_Status::Ok)
{
con = inFile.read();
quotationId = conPeek(con,1);
worker = conPeek(con,2);
salesQuotationTable = salesQuotationTable::find(quotationId,true);
if(salesQuotationTable && worker) {
ttsBegin;
// Obviously, this is not working working because I am trying to update the RecId field with a string value.
salesQuotationTable.WorkerField = worker;
salesQuotationTable.update();
ttscommit;
}
info("Done!");
}
}
您可以使用HcmWorker表上的静态函数findByPersonnelNumber
按人员编号查找HcmWorker记录。只需替换salequotationtable.WorkerField=worker代码>带有
salesQuotationTable.WorkerField = HcmWorker::findByPersonnelNumber(worker).RecId;