Thanks
Using the .NET business connector will require you to instantiate all of the
classes necessary to create a datasource. I did this with the COM connector
in 3.0, and it was a lot work.
I have just completed a custom interface using the AIF webservice to process
data feeds from legacy mainframes and a .Net GUI application. I had to
understand the axd and ax class interactions.
thanks in advance
you can now set breakpoints in the axd.. classes.
static void AIFSend(Args _args)
{
AifEndpointId destEndpointId;
AifActionId actionId;
AifEntityKeyList entityKeyList;
AifMessageXml documentXml;
AifMessage message;
XMLDocument xmldoc;
str strxml;
;
destEndpointId = 'createListBooking';
actionId = 'createListBooking';
xmldoc = new XMLDocument();
doc.load(@"F:\dynamics\AIF\CreateListBooking.xml");
strxml = xmldoc.toString();
TTSBegin;
message = AifMessage::deserialize(strxml,destEndpointId);
message.actionId(actionId);
entityKeyList = AifDocumentBroker::create(message);
TTSCommit;
}
To answer your question regarding call methods from .net.
You create a class in X++ that performs the functions you need and then from
.net
call the static method(s).
using Microsoft.Axapta.BusinessConnector;
namespace BCNetSample1
{
/// <summary>
/// This sample uses the .NET Business Connector to
/// call an Axapta class static method.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application
/// </summary>
[STAThread]
static void Main(string[] args)
{
Microsoft.Axapta.BusinessConnector.Axapta ax;
string sID = "@SYS21669";
object o;
bool b;
try
{
// Create an Axapta object.
ax = new Axapta();
// Log on to Microsoft Dynamics AX.
ax.Logon("","","","");
}
catch (Exception e)
{
Console.WriteLine("An error occurred in object creation or Axapta logon:
{0}", e.Message);
return;
}
// Logon was successful.
try
{
// Call a static class method.
// In this example, call SysLabel::labelId2String2 to determine
// the label string for a given label ID.
o = ax.CallStaticClassMethod("SysLabel", "labelId2String2", sID);
}
catch (Exception e)
{
Console.WriteLine("An error has been encountered during
CallStaticClassMethod: {0}", e.Message);
b = ax.Logoff();
return;
}
// Output the returned string.
Console.WriteLine("The label string for {0} is {1}", sID, o.ToString());
// Log off from Axapta.
b = ax.Logoff();
Thanks
If you want to call this as part of the processing of an standard action.
1. Add a function your Axd Class that will manage the action (Pre-process or
post-process the message before calling the standard handler).
2. Edit the function GetActionList from your axd class and change the entry
for the action that you want to modify to call your function.
Ricardo Venegas [MSFT]
--
This posting is provided "AS IS" with no warranties, and confers no rights
"mhr" <m...@discussions.microsoft.com> wrote in message
news:87B585AF-10F2-42DF...@microsoft.com...
I need this method while I read the Ax Table in .net. So I think this method
needs to be called during processing of the standard action "Read".
I tried once what you said about adding method to the Axdclass. But i didnt
know how i can use it afterwards.
Could you please explain more about the second step ("Edit the function
GetActionList from your axd class and change the entry
for the action that you want to modify to call your function. ")
Thanks
If you need to call the method as part of a "standard method", i.e. a method
that comes out of the box, you would have to override that method. You do so
by opening the respective class in the AOT, navigating to the method and
editing it (e.g. adding the call to your method where you need it). Be sure
that you still execute the original code -- if you need that as well.
If you want to expose a (arbitrary) method on an Axd document class (the
class MUST inherit from AxdBase), more specifically a method that is not one
of the methods that comes with AX or that can be generated (i.e. create,
createList, read, readList, findList, findEntityKeyList), then you need to do
basically what Ricardo has recommended. Here are a few more details:
1) Open the AOT, navigate to “Classes”, double-click on the class to which
you want to add the new action.
2) Selects getActionList in the list on the left hand side of the form.
3) Create a new AifActionInfo record and add it to the method similar to the
following:
"//registering Delete method
aifActionInfo = new AifActionInfo();
aifActionInfo.parmActionId("DisplayName"); // Shows up on the “Action”
form
aifActionInfo.parmActionType(AifActionType::SendDocument); // Action
type, see below
aifActionInfo.parmExternalName("myExternalName");
aifActionInfo.parmMethodName("myMethodName"); // Name of the X++ method
aifActionInfo.parmLabel("someLabel");
aifActionInfo.parmDescription("someDescription");
aifActionInfo.parmDisplayMenuItemName(
menuitemdisplaystr(AifDocConfiguration));
actions.add(aifActionInfo);"
Save and close the dialog.
4) Right-click on the class to which you want to add the new action, select
"New Method", implement the method. Note that the implemented method must be
of the signature that is implicitly specified in 3), in
"aifActionInfo.parmActionType(AifActionType::SendDocument);". SendDocument,
used in the above code fragment for instance, would have to be a method of
the following signature:
AifDocumentXML <sendMethodName>( AifEntityKey entityKey, AifSchemaInfo
xsdInfo, AifEndpointActionPolicyInfo actionPolicyInfo, AifConstraintList
constraintList, AifPropertyBag propertyBag);
Note that each action that comes “out of the box”, implements either this or
one of the other supported signatures:
- SendDocumentList: AifDocumentXML < sendMethodName >( AifEntityKeyList
entityKeyList, AifSchemaInfo xsdInfo, AifEndpointActionPolicyInfo
actionPolicyInfo, AifConstraintListCollection constraintListCollection,
AifPropertyBag propertyBag);
- ReceiveDocument: AifEntityKey <createMethodName>( AifDocumentXMLxml,
AifEndpointActionPolicyInfo actionPolicyInfo, AifConstraintList
constraintList);
- ReceiveDocumentList: AifEntityKeyList <createMethodName>(
AifDocumentXMLxml, AifEndpointActionPolicyInfo actionPolicyInfo,
AifConstraintListCollection constraintListCollection);
- QueryEntityKeys: AifEntityKeyList <queryMethodName>( AifQueryCriteria
queryCriteria, AifEndpointActionPolicyInfo actionPolicyInfo);
- QueryDocuments: AifDocumentXML <queryMethodName>( AifQueryCriteria
querycriteria, AifSchemaInfo xsdInfo, AifEndpointActionPolicyInfo
actionPolicyInfo, AifConstraintListCollection constraintListCollection,
AifPropertyBag propertyBag);
5) Save your changes, compile the class, click “Scan and register” on the
Basic -> AIF -> Action form.
Now, if you open the Basic -> AIF -> Action form, you can see your method as
one of the actions on the respective document class. Note that this is an
advanced topic and as with all customizations, you need to be careful with
overriding any defaults.
Hope this helps,
-michael
--
This posting is provided "AS IS" with no warranties, and confers no rights.