问题描述
是否可以在axapta中插入,更新或删除crossCompany?
is possible to make insert, update or delete crossCompany in axapta?
我正在尝试这样做,在我的查询中调试有这个:
i am trying to do that, debugging in my query i have this:
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;
}
我尝试调试并调试,但无法在方法tlRemoteLocationInfo.update()中更新,例外是:
i have a try catch, and debugging, fails to update in the method tlRemoteLocationInfo.update(), the exception is:
我想念什么吗?
推荐答案
您不能使用crossCompany
关键字进行更新操作.看这里: https://msdn.microsoft.com/en-us/library/cc518738. aspx
You can't do update operations using the crossCompany
keyword. See here:https://msdn.microsoft.com/en-us/library/cc518738.aspx
我重写了您的代码,以便它可以正常工作.如果正在CIL中运行,请确保进行增量CIL编译.第二种方法是,如果您想进行片刻选择.
I rewrote your code so that it should work. And make sure to do an incremental CIL compile if this is running in CIL. The second method is if you wanted to do a while-select.
// 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;
}
}
这篇关于如何更新/插入/删除CrossCompany的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!