Discussion:
Dynamics AX EP Problem with Dataset method call
(too old to reply)
Iven
2010-05-22 18:49:01 UTC
Permalink
Hello,

I want to realize a webpart in our EP where our supplier can confirm the
dispatch of our purchase.
In the Weppart I have two textboxes for the PurchId and the LineNum and a
button with a clicked event. When pressing the button the AXDatasourche
(Purchline) should be filtered to the current purchase.

So I added a method to the DataSet in AX called setRanges:

void setRanges(ProdId _prodId, LineNum _lineNum)
{
;
PurchIdQbr.value(_prodId);
LineNumQbr.value(strfmt('%1', _lineNum));

PurchLine_DS.executeQuery();
}

In the clicked event of the Button, I call the DataSet method:

PurchLine_DS.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("setRanges",
PurchId.Text, Convert.ToDecimal(LineNum.Text));


This works fine when I press the button shortly after the web page was
loaded. When I wait about 30 seconds before I press the butten I get a error
message, that the buisiness connector is not longer avaiable:

Microsoft.Dynamics.Framework.BusinessConnector.Session.Exceptions.NoKernelSessionException: No .NET Business Connector session could be found.


I dont have this problem when I call a static method of a class, there I can
wait several minutes and the method call doesn't crash:

Exapmle:
AxBaseWebPart.GetWebpart(this).Session.AxaptaAdapter.CallStaticClassMethod("WK_EPBoxAdvice",
"existsPurchLine", PurchId.Text, Convert.ToInt32(LineNum.Text));


Has anybody an idea how I can solve this problem?

Thanks,
Iven
Jack T
2011-01-21 11:57:24 UTC
Permalink
Recently I faced exactly the same issue.
As I found out later - the reason of the error is - queryBuildRange object (the one you declared in ClassDeclaration and create in init()) is getting lost after a short period of time.
So, solution is simple:
you have to re-create range object every time before change the value. Like this:

QueryBuildRange myRange;
;
myRange = SysQuery::findOrCreateRange(MyTable_q.dataSourceTable(tablenum(MyTable)), fieldnum(MyTable, MyField));
myRange.value(queryValue("my value"));
MyTable_ds.executeQuery();

This topic is also very helpful as it is related to the same approach:
http://blogs.msdn.com/b/epblog/archive/2008/06/21/how-to-update-data-set-for-axdatasource-control.aspx

Regards,
Jack
Post by Iven
Hello,
I want to realize a webpart in our EP where our supplier can confirm the
dispatch of our purchase.
In the Weppart I have two textboxes for the PurchId and the LineNum and a
button with a clicked event. When pressing the button the AXDatasourche
(Purchline) should be filtered to the current purchase.
void setRanges(ProdId _prodId, LineNum _lineNum)
{
;
PurchIdQbr.value(_prodId);
LineNumQbr.value(strfmt('%1', _lineNum));
PurchLine_DS.executeQuery();
}
PurchLine_DS.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("setRanges",
PurchId.Text, Convert.ToDecimal(LineNum.Text));
This works fine when I press the button shortly after the web page was
loaded. When I wait about 30 seconds before I press the butten I get a error
Microsoft.Dynamics.Framework.BusinessConnector.Session.Exceptions.NoKernelSessionException: No .NET Business Connector session could be found.
I dont have this problem when I call a static method of a class, there I can
AxBaseWebPart.GetWebpart(this).Session.AxaptaAdapter.CallStaticClassMethod("WK_EPBoxAdvice",
"existsPurchLine", PurchId.Text, Convert.ToInt32(LineNum.Text));
Has anybody an idea how I can solve this problem?
Thanks,
Iven
Submitted via EggHeadCafe
Twitter Search API with jQuery and JSONP
http://www.eggheadcafe.com/tutorials/aspnet/94d7bda5-c477-4ff9-b71d-e24e5fc70c24/twitter-search-api-with-jquery-and-jsonp.aspx
Loading...