Luegisdorf
11/4/2005 2:09:00 PM
Hi Eric
I''m going right wiht you that changeCompany isn''t aviable trough COM
Connector.
But I think you can use this workaround instead:
1. In Axapta build a class with just one static method looks like this:
static void runCodeInExplicitCompany(AreaId _area, str _codeToRun)
{
;
changeCompany(_area)
{
runbuf ("void jobX(){ " + _codeToRun + " }");
}
}
2. use now COM Connector like this (vb.net example):
Dim ax As AxaptaCOMConnector.Axapta2
Dim s As String
REM logon and so on ...
s = "CustTAble custTAble;" + vbCrLf
s += ";" + vbCrLf
s += "ttsbegin;" + vbCrLf
s += "select firstonly forupdate custTable;"
s += "custTAble.Name = " & Chr(34) & "dudelidu" & Chr(34) & ";"
s += "custTable.update; ttscommit;"
ax.CallStaticClassMethod("TheNewClass", "runCodeInExplicitCompany",
"DAT", s)
I know that''s a little bit ugly. But may be you can make it more easier
(depends what you want to do exactly). But I don''t see any other possiblity
to run code under special company from COM Connector.
Best regards
Patrick
"EricR" wrote:
> if your using the COM connector how can you change companies?
>
> I know the following works inside Axapta:
>
> ChangeCompany( TargetCompany )
> {
> // Do something
> }
>