是否可以在axapta中插入,更新或删除crossCompany?
我正在尝试这样做,在我的查询中调试我有这个:
select forUpdate crossCompany tlRemoteLocationInfo
where tlRemoteLocationInfo.RemoteLocationId == "someId";
if (tlRemoteLocationInfo.RecId)
{
ttsBegin;
changeCompany(tlRemoteLocationInfo.dataAreaId)
//then i make mi update to fields and then i make this:
tlRemoteLocationInfo.update();
ttsCommit;
}
我有一个try catch,并且调试,无法在方法tlRemoteLocationInfo.update()中更新,例外是:
$ exception {“Se produjounaexppcióndetipo 'Microsoft.Dynamics.Ax.Xpp.ErrorException'。“} System.Exception {Microsoft.Dynamics.Ax.Xpp.ErrorException}
我错过了什么?
答案 0 :(得分:7)
您无法使用crossCompany
关键字执行更新操作。看这里:
https://msdn.microsoft.com/en-us/library/cc518738.aspx
我重写了你的代码,以便它可以工作。如果在CIL中运行,请确保执行增量CIL编译。第二种方法是你想做一次选择。
// Rewrite 1 - Notice removal of "forUpdate"
select firstOnly crossCompany tlRemoteLocationInfo
where tlRemoteLocationInfo.RemoteLocationId == "someId";
if (tlRemoteLocationInfo)
{
changeCompany(tlRemoteLocationInfo.dataAreaId)
{
// Notice this line
tlRemoteLocationInfo.selectForUpdate(true);
ttsBegin;
//then i make mi update to fields and then i make this:
tlRemoteLocationInfo.update();
ttsCommit;
}
}
// Rewrite 2 - Is a "while select" what you want?
while select crossCompany tlRemoteLocationInfo
where tlRemoteLocationInfo.RemoteLocationId == "someId"
{
changeCompany(tlRemoteLocationInfo.dataAreaId)
{
// Notice this line
tlRemoteLocationInfo.selectForUpdate(true);
ttsBegin;
//then i make mi update to fields and then i make this:
tlRemoteLocationInfo.update();
ttsCommit;
}
}