Wednesday, 9 September 2020

Deploy reports from powershell in D365 FinOps

 

 Open powershell in admin mode and execute the below command :


C:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “C:\AosService\PackagesLocalDirectory”

 


Thursday, 10 December 2015

AXBuild command in AX2012

Instead of compiling the application from AOT which takes long time there is another way to compile the whole application through AXBuild command.

Goto the path where Ax is located.
For example :
C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin

then on the bin folder --> shift + right click --> open command window here --> ax32.exe is opened.

Then on the command window type

Axbuild.exe xppcompileall /s=01

NOTE : If you have one AOS then type /s=01, if you have more AOS then specify the correct AOS.


Adding filter on display fields in ax2012

Here is a sample example scenario where you add a display field on the form and make this field to be allowed to filter.

Create a table TEST



Create form TEST




Data source à TEST
Add fields Test_Id, Test_ActivityNumber, ActivityName from the datasource TEST
FormControl à Activity name à auto declaration YES
Data method à displayActivityName

Then override context method on the formcontrol and write the following code :

public void context()
{
    int             selectedMenu;
    formrun         fr;
    Args            ag;
    Name            strtext;
    querybuilddataSource qb1;
    queryrun    qr;
    query       q;
    PopupMenu menu = new PopupMenu(element.hWnd());
    int a = menu.insertItem('Filter By Field');
    int b = menu.insertItem('Filter By Selection');
    int c = menu.insertItem('Remove Filter');
    ;


    q   = Test_ds.query();
    qb1 = q.dataSourceTable(tablenum(Test));
    qb1 = qb1.addDataSource(TableNum(smmActivities));
    qb1.addLink(FieldNum(Test,ActivityNumber),FieldNum(smmActivities,ActivityNumber));

    selectedMenu = menu.draw();
    switch (selectedMenu)
    {
    case -1: //Filter by field
            break;
    case a:
            ag = new args('SysformSearch');
            fr = new formrun(ag);
            fr.run();
            fr.wait();
//Reading User entered value for filter process
            strtext = fr.design().controlName('FindEdit').valueStr();
            if(strtext)
            {
//Creating a query for filter

                qb1.addRange(FieldNum(smmActivities,Purpose)).value(strtext);
                Test_ds.query(q);
                Test_ds.executeQuery();
            }
            break;

    case b:                                      // Filter By Selection

            qb1.addRange(FieldNum(smmActivities,Purpose)).value(ActivityName.valueStr());
            Test_ds.query(q);
            Test_ds.executeQuery();
            break;

    case c :                                      // Remove Filter
            q   = new Query();
            qb1 = q.addDataSource(tablenum(Test));
            qb1.clearLinks();
            qb1.clearRanges();
            Test_ds.query(q);
            Test_ds.removeFilter();
            break;

    Default:
            break;

    }
}








Wednesday, 9 December 2015

Report shows no data --- Ways to solve them

When report data is not printed correctly or code wise data is perfect and data is also inserted in temp table correctly then also if data is not printed in report then follow these steps -->

1) Clear the caches
2) Delete the AUC files
3) Delete the report from the report server
4) Restart SSRS services
5) Redeploy report from visual studio
6) Check the report
7) Then also this doesnt work then restart AOS

Ways to solve workflow stopped error in ax2012


1) Check whether user is assigned to workflow execution account in the path
System Administration --> Setup --> System --> System service account -->

2) Check whether appropriate permissions are given to the user assigned to workflow account.

3) Check in server configuration -->
whether Is batch server is CHECKED.

4) Rerun the Worflow infrastructure configuration in the path
System Administration --> Setup --> Workflow --> Worflow infrastructure configuration -->

5) Check whether the batch group assigned to workflow is connected to correct AOS in the path -->
System Administration --> Setup --> Batch group

6) Do the full CIL and AOS restart and then solve the errors in Xppil folder and then check the workflow.
If it is not solved then follow these steps :
Is Batch Server -- uncheck
Stop the AOS
Rename Xppil folder
Restart the AOS
Generate full CIL and then check for errors and check the workflow.

7) Find out the exact reason for the error in Event log where AOS is installed.

8) Check Inbound ports in the path
System Administration --> Setup --> Services and Application Inegration Framework --> Inbound ports -->

Check whether sys workflow services are active if not activate them.
Deactivate AxClient and AIF services and then activate it.

9) Open configuration utility and refresh the WCF configuration.

10) Check if the SID of the admin user in the UserInfo table has the correct value.

Display method on InventOnHandItem form in ax2012

Adding two new fields on the InventOnHandItem form :
  1. Add two controls in the grid dimension and supplier.
  2. On the InventSum datasource add 2 new display methods to display data in these fields on the form.
Display method for dimension :

Display public AttributeValueText displayDimension(Inventsum _inventSum)
{
    PdmProduct              pdmProduct;
    PdmProductItem          pdmProductItem;
    PdmProductItemAttribute pdmProductItemAttribute;
    EcoResProduct           ecoResProduct;
    AttributeValueText      returnValue;
    EcoResValue             ecoResValue;
    EcoResAttribute         ecoResAttribute;

    ecoResProduct   = EcoResProduct::findByDisplayProductNumber(_inventSum.ItemId);

    select Attribute,Value from pdmProductItemAttribute
    join pdmProductItem
    where pdmProductItem.RecId     == PdmProductItemAttribute.ProductItem
    join pdmProduct
    where pdmProduct.RecId         == pdmProductItem.ProductRecId
       && pdmProduct.EcoResProduct == ecoResProduct.RecId
    join ecoResAttribute
    where ecoResAttribute.RecId    == pdmProductItemAttribute.Attribute
       && ecoResAttribute.Name     == "Dimension";
    {
        ecoResValue = EcoResValue::find(pdmProductItemAttribute.Value);
        returnValue = ecoResValue.value();
    }

    return returnValue;
}

Display method for Supplier :

Display public AttributeValueText displaySupplier(Inventsum _inventSum)
{
    PdmProduct              pdmProduct;
    PdmProductItem          pdmProductItem;
    PdmProductItemAttribute pdmProductItemAttribute;
    EcoResProduct           ecoResProduct;
    AttributeValueText      returnValue;
    EcoResValue             ecoResValue;
    EcoResAttribute         ecoResAttribute;

    ecoResProduct   = EcoResProduct::findByDisplayProductNumber(_inventSum.ItemId);

    select Attribute,Value from pdmProductItemAttribute
    join pdmProductItem
    where pdmProductItem.RecId     == PdmProductItemAttribute.ProductItem
    join pdmProduct
    where pdmProduct.RecId         == pdmProductItem.ProductRecId
       && pdmProduct.EcoResProduct == ecoResProduct.RecId
    join ecoResAttribute
    where ecoResAttribute.RecId    == pdmProductItemAttribute.Attribute
       && ecoResAttribute.Name     == "Supplier";
    {
        ecoResValue = EcoResValue::find(pdmProductItemAttribute.Value);
        returnValue = ecoResValue.value();
    }

    return returnValue;
}

4. Now on the newly added form control --> dimension  --> in the properties window -->
datasource  -- InventSum
datamethod -- displayDimension

5. supplier -->
datasource  -- InventSum
datamethod -- displaySupplier


Friday, 3 April 2015

Export Data with Outbound ports in AX 2012

Outbound ports are not related with web services or network at all (talking about WCF, bindings and endpoints). You can use it in order to retreive data from Dynamics AX and send the results to either a file or a message queue (MSMQ).


The following post will show a summary of the steps I followed in order to export customers in several XML files into a directory on the AOS server.






1)  Create an outbound port specifying "File system adapter" as adapter.
You can limit it to a specific company if you want
In the operations choose : CustCustomerService.read

This service operation will be used to read a customer from AX by specifying an account number.
The output result of the operation will be the customer itself.



2)  I create a new folder on the AOS side (in the example C:\AIFOutboundTest)
    Don't forget to give the correct write access rights for the user executing your AOS Service. The AOS will need write access to create the file.

3)  Specify the newly created folder in the URI of the outbound port and save the outbound port and activate it.

4)  Create a new job to post some customer in the AIF Queue :



static void sendCustomerOutbound(Args _args)
{

    AxdSendContext axdSendContext = AxdSendContext::construct();
    AifEntityKey aifEntityKey = AifEntityKey::construct();
    Map keyData;
    AifConstraintList aifConstraintList = new AifConstraintList();
    AifConstraint aifConstraint = new AifConstraint();

    CustTable       custTable;
    ;

    custTable = CustTable::find("US-001");

    keyData = SysDictTable::getKeyData(custTable);

    aifEntityKey.parmTableId(custTable.TableId);
    aifEntityKey.parmRecId(custTable.RecId);
    aifEntityKey.parmKeyDataMap(keyData);

    axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
    axdSendContext.parmSecurity(false);

    aifConstraint.parmType(AifConstraintType::NoConstraint) ;
    aifConstraintList.addConstraint(aifConstraint) ;

    AifSendService::submitDefault(
        classnum(CustCustomerService),
        aifEntityKey,
        aifConstraintList,
        AifSendMode::Async,
        axdSendContext.pack());

}

5)  Once this code is executed, a new record will be created in the AIF Queue manager.

You can reach the queue manager with the following path :
System Administration > Periodic > Services and Application Integration Framework > Queue manager

Status will be ready and you will see the document service operation involved.




6)  Now the instructions are created with correct parameters. You can either setup a batch system that will automatically execute the following method, or you can simply execute it manually.

static void runAIF()
{
    AifOutboundProcessingService outbound = new AifOutboundProcessingService();    outbound.run();
}

7)  Once this method has been executed, you will be able to see the resulting newly created AIF message (XML result). For this, use the following menu : Document Log and View message.




8)  Once the message has been created, we can execute the following method :

static void sendAIF()
{
    AifGatewaySendService        send     = new AifGatewaySendService();
    send.run();
}

9)  This operation will export the message to a physical XML file on the folder we specified in the outbound port.