I am making some customizations to the Warehouse mobile portal in Dynamics AX 2012 R3 CU12. I have put together code and it works as expected when I debug and run it from the AOT by running the WHSWorkExecute form. But when I run it from the web browser it is not functioning as it does when I run it from the AOT by running the form.
As part of the customization, I have this method in x++. When this method is executed on the server it seems like the _buttonClicked parameter (being an x++ str) it is not properly marshaling to the .NET string please see the code below. I am not sure if I am missing something but the switch case is not picking up the string value that is coming in for the _buttonClicked parameter.
private Qty masGetTotalQty(Qty _totalQty, Qty _qtyCounted, str _buttonClicked = "")
System.String strReCount, strAdd;
strLocal = _buttonClicked;
strButtonClicked = strLocal.ToString();
strReCount = "ReCount";
strAdd = "Add";
return _qtyCounted + _totalQty;
I have the below macros defined at the class level
//I have these macros defined at the class level #define.RFAdd('Add') #define.RFBackToItem('BackCount') #define.QtyCounted('QtyCuonted') #define.RFReCount('Recount')
It always executing the default block of the switch case and not being able to identify the button that was clicked on the browser. In the case of a AX web service I can debug the code from Visual studio by attaching the AX32Serv.exe but I am not sure how can I debug from the browser in the case of the mobile client.
Am I missing something here?
Why don't you simply use _buttonClicked in the switch statement? Copying the value to System.String object can't bring you any value, but maybe it's the cause of your problem. I'm not sure that there is an automatic marshalling from .NET types to X++ types inside switch(); it's not an assignment. For these reason, please remove those .NET types and stick to X++.
Also, maybe you don't get any value in _buttonClicked - using the debugger should help you to understand what's going on.
Martin, Just to provide an update that the issue was with something else in the code. As you mentioned it doesn't complain about the datatypes after the code was fixed. Thanks.