not able to run job in batch
static void Job47(Args _args)
{
str path,stx;
TreeNodeIterator iter;
TreeNode treeNode, treeNodeToRelease;
Map dictMenuDisplay;
FormName formName;
MenuItemName menuItemName;
container conMenu;
int i,n;
;
for (n=1;n<=1;n++)
{
info::messageWinAddLine(strfmt("iter:%1",n));
path ="Menu Items\\Display";
dictMenuDisplay = new Map(Types::String,Types::Container);
treenode = Treenode::findNode(path);
iter = treenode.AOTiterator();
treenode = iter.next();
while (treenode)
{
formName = treenode.AOTgetProperty("Object");
menuItemName = treenode.AOTname();
if (dictMenuDisplay.exists(formName))
{
conMenu = dictMenuDisplay.lookup(formName);
conMenu = conIns(conMenu,conlen(conMenu)+1,menuItemName);
dictMenuDisplay.insert开发者_如何学编程(formName,conMenu);
}
else
dictMenuDisplay.insert(formName,[menuItemName]);
treenode = iter.next();
}
}
}
When I run the above job in batch it shows the following error "The server side impersonated(RunAs) session tried to invoke a method available for client-side processing only" and points to the line info::messageWinAddLine(strfmt("iter:%1",n)); I have tried putting false in the method runsImpersonated() in class RunbaseBatch. But doesnt seems to work either.
I am new to AX2009 so dont really understand what it means to running job in client or in server, kindly lead me to the right direction.
First, remove the modification to the RunBaseBatch class. That method is mean to be overridden in any classes extending that class (inheritance). Take a look at the class "Tutorial_RunbaseBatch" for insight on how the RunBaseBatch pattern can be achieved.
Now, also consider that when you run x++ code, it can be run either client-side or server-side. You can have methods locked for which side you allow the code to run. The GLobal::info-method can run both client- and server-side. When you activate a batch to run a class (not a job), a class extending RunBaseBatch, then the Batch Framework will run the class server side according to your settings. Your code should then be independent of client-side, meaning there can not be any line of code that requires access to client-side. WinAPI::moveFile is an example.
Hope this helps a bit.
精彩评论