Thursday, June 13, 2013

Find a field -- ProfessionalTitle

select * from syscolumns A inner join sysobjects B
on A.id = B.id
where A.name = 'professionaltitle'

select professionaltitle,* from DMFEMPLOYEEENTITY where professionaltitle <> ''
select professionaltitle, * from dirpartytable where professionaltitle <> ''

AX Reference Sources

AX Server Team Blog:
http://blogs.msdn.com/b/daxserver/archive/2013/05.aspx
 
AX Support Blog:
http://blogs.msdn.com/b/axsupport/
 
AX Demo/Sample Solution Site:
https://mbs.microsoft.com/Cms/Templates/document/General.aspx?NRMODE=Published&NRNODEGUID=%7bACA31BB9-CB57-4B7F-A948-880FAEF28099%7d&NRORIGINALURL=%2fpartnersource%2fdeployment%2fmethodology%2fvpc%2fAX2012DemoToolsMaterials&NRCACHEHINT=Guest
 
AX UK Blog
http://blogs.msdn.com/b/ukax/
 
AX Business Intelligence
http://blogs.msdn.com/b/dynamicsaxbi/
 
http://blogs.msdn.com/b/saveenr/
 
http://blogs.msdn.com/b/mfp/

Table Permissions Framework

Set up TPF: http://msdn.microsoft.com/en-us/subscriptions/hh965683.aspx
Set up Record level permission: http://blogs.msdn.com/b/daxserver/archive/2013/05/13/enabling-field-level-authorization-in-ax-2012.aspx

Join 2 Tables

    Address addressTable2;
    AddressState addressStateTable3;
    struct sut4;
    ;
    sut4 = new struct("str StateName; str StateId; str Phone");

    while select *
        from addressTable2
            order by addressStateTable3 .Name
                , addressTable2 .Phone
        join addressStateTable3
            where addressTable2 .State ==
                addressStateTable3 .StateId
                && addressTable2 .State LIKE "N*"
    {
        sut4.value("StateName", addressStateTable3 .Name );
        sut4.value("StateId", addressStateTable3 .StateId );
        sut4.value("Phone", addressTable2 .Phone );

        info(sut4.toString());
    }

Group and Order
static void SelectGroupBy6Job(Args _args)
{
    Address tabAddress;
    AddressState tabAddressState;
    ;
    info("Start of job.");

    WHILE SELECT
        count(RecId)
        from tabAddress
        join tabAddressState
            GROUP BY
                tabAddress .State
                ,tabAddressState .Name
            ORDER BY tabAddress .State desc
            where
                tabAddress .State like "*N*"
                && tabAddressState .StateId == tabAddress .State
    {
        info(strFmt
            ("%1 = Count , StateId = %2 , StateName = %3"
            ,tabAddress .RecId ,tabAddress .State
            ,tabAddressState .Name
            ));
    }
    info("End of job.");
}

Tuesday, June 11, 2013

label files

C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\Application\Appl\Standard
AxSysen-us.ald

Sunday, June 9, 2013

select for update

static void UpdateOrg(Args _args)
{
Organization tstOrg;
ttsBegin;
while select forupdate * from tstOrg
{
tstOrg.State = "IL";
tstOrg.NumberOfEmployees = tstOrg.NumberOfEmployees+10;
tstOrg.update();
}
ttsCommit;
}

Friday, June 7, 2013

Call WebService from AX

Create class library project in VS, add services references, add to AOT, and deploy the project to both AX server and client.
In AX, add code some reference code.

VERAxServicesNameServcies.AxCustomerSvc.CustomerClient customerClient;
    VERAxServicesNameServcies.AxCustomerSvc.ICustomer customer;
    System.Exception Exception;
     System.ServiceModel.Description.ServiceEndpoint endPoint;
    System.ServiceModel.EndpointAddress endPointAddress;
    System.Type type;
    ;
    try
    {
        // Create a service client proxy
        type= CLRInterop::getType('VERAxServicesNameServcies.AxCustomerSvc.CustomerClient');
        customerClient = AifUtil::createServiceClient(type);
          // Create and endpoint address, This should be a parameter stored in the system
        endPointAddress = new System.ServiceModel.EndpointAddress("http://10.242.25.20:8081/Customer.svc");
        // Get the WCF endpoint
        endPoint = customerClient.get_Endpoint();
        // Set the endpoint address.
        endPoint.set_Address(endPointAddress);
        // Use the zipcode to find a place name
        //customer= customerClient.GetCustomer(1);
        // Use the getAnyTypeForObject to marshal the System.String to an
        //Ax anyType
        // so that it can be used with info()
        info(strFmt('%1', CLRInterop::getAnyTypeForObject(customerClient.GetCustomerTest(1))));
    }
    catch
    {
        // Get the .NET Type Exception
        exception = CLRInterop::getLastException();
        // Go through the inner exceptions
        while(exception)
        {
            // Print the exception to the infolog
            info(CLRInterop::getAnyTypeForObject(exception.ToString()));
            // Get the inner exception for more details
            exception = exception.get_InnerException();
        }
    }