2016-02-12 112 views
1

是否可以在axapta中插入,更新或删除crossCompany?如何更新/插入/删除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; 
} 

我有一个尝试捕捉,调试,故障的方法tlRemoteLocationInfo.update()来更新,异常是:

$ {例外 “富硒produjo UNAexcepción德TIPO 'Microsoft.Dynamics.Ax.Xpp.ErrorException'。”} System.Exception的 {} Microsoft.Dynamics.Ax.Xpp.ErrorException

我错过了些什么?

回答

6

您不能使用crossCompany关键字执行更新操作。在这里看到: https://msdn.microsoft.com/en-us/library/cc518738.aspx

我改写了你的代码,以便它应该工作。如果在CIL中运行,请确保执行增量式CIL编译。第二种方法是如果你想做一段时间的选择。

// Rewrite 1 - Notice removal of "forUpdate" 
select 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; 
    } 
} 
+0

几秒钟后,我找到了解决方案,比如你给,谢谢,它有帮助 –