Monday 25 June 2018

link the SalesLine (Inventdim) ConfigId to EcoResProductMasterConfiguration in ax 2012

link the SalesLine (Inventdim) ConfigId to EcoResProductMasterConfiguration


Please use the following code/job to link required salesLine with ecoResProductMasterConfiguration.
static void EcoResProductMasterConfiguration(Args _args)
{
    EcoResProductMasterConfiguration config;
    SalesLine                        salesLine;
    InventDim                        inventDim;
    EcoResProductMaster              productMaster;
    InventTable                      inventTable;
    
    while select * from salesLine
    where salesLine.SalesId == "XYZ"
    join inventDim
    where inventDim.inventDimId == salesLine.InventDimId
    join inventTable
    where salesLine.ItemId == inventTable.ItemId
    join productMaster
    where inventTable.Product == productMaster.RecId
    join config
    where config.ConfigProductMaster == productMaster.RecId
    {
        info(strFmt("%1", config.ConfigProductMaster));
    }
}

Sunday 17 June 2018

very useful codes in ax 2012

very useful ! thank you!<BR/><BR/>just in case if somebody like me wants to clear Dynalinks between two forms I might suggest to add in Init() on DataSource of the second form after method Super() the following:<BR/><BR/> if (element.args() && element.args().record() && element.args().record().tableId == tableNum(YourTable1))<BR/> {<BR/> CurrentTable_ds.query().dataSourceNo(1).clearDynalinks();<BR/> }

source

Friday 15 June 2018

How to use Event Handler in Microsoft Dynamics AX 2012

How to use Event Handler in Microsoft Dynamics AX 2012



Microsoft incorporated lot of beautiful new features in Dynamics AX 2012 and one of them is Event Handler. It’s a very nice feature of Dynamics AX 2012 which allows you trigger an event after or before an activity.
So today am going to tell you about these features:
  Ø  In Microsoft Dynamics AX 2012 how to handle event on different methods / occurrences.

  Ø  In Microsoft Dynamics AX 2012 how to implement or apply pre or post event handler.
  Ø  How to develop an event handler step by step in Microsoft Dynamics AX 2012.
  Ø  What is new in Microsoft Dynamics AX 2012 from programming point of view?
  Ø  X++ Event handling in Dynamics AX 2012.

You should invoke events over using pre or post events on methods.

Pre-Event Handlers and Post-Event Handlers

An event handler can reside underneath a method node can run either before or after the method runs. You can use CalledWhen property on the event handler node. The CalledWhen property has two values:

• Pre – The event handler runs before the method starts.
• Post – The event handler runs after the method ends.

A new class the XppPrePostArgs Parameter is being used by event handlers.

A pre-method event handler that has only an XppPrePostArgs parameter can inspect and change the values of the parameters.

Similarly a post-method event handler that has only an XppPrePostArgs parameter can inspect and change the return value from the method.

When an XppPrePostArgs object is used, the values of the parameters and the return type can be changed by the event handler. The values can be changed even if the parameters and return type are value types, such as an integer or string. If a parameter or a return type is a reference to an object, the event handler can call methods on the object and could change the state of the object.

Event handlers can run only on the same tier as the publisher class of the delegate runs on. For instance, if the publisher class has its RunOn property set to Server, to declare a method with client keyword and call a subscribed event handler method is not allowed.

You can use X++ event as well as .Net made managed code event. You can define it at Event handler proper called EventHandlerType.

How to use event handlers in Microsoft Dynamics AX 2012 step by step:

1) Open your new developer work space and go to AOT then classes node.

2) Right click on Classes node and click on New Class as shown below. 




3) By default system will give a name to it. Here in my case it’s Class1. Right click on newly created class and click on Rename shown below.





4) After clicking Rename, give a name called CustTableEventHandler to it. Here I am going to develop an event to be applied on CustTable so that is the reason why I decided this name (CustTableEventHandler). After renaming this class, it looks as shown below.




5) Right click on class CustTableEventHandler then New then Pre- or post-event handler as shown below.



6) Once you click on this, system gives you a method as shown below. 





7) Customize the method as shown below. 





8) Here args is providing current record to custTable instance and info is displaying the current customer account. The code snippet is below.

public static void custCreateInfo(XppPrePostArgs _args)
{
     CustTable custTable;
     custTable = _args.getThis();

     info(strFmt("Customer account %1 has been created", custTable.AccountNum));
}

This method I support to call from insert method of CustTable with type post event. It means that once insertion is done to CustTable, system will display recently inserted customer account number. It depends on your business requirement what logic you want to apply here. So here you can develop your required business logic or invoke pre built logic.

9) Go to Tables node in AOT then find out CustTable.





10) Go to insert method of CustTable and right click on it then click on New Event Handler Subscription as shown below.




11) After clicking you will get a new Event handler shown below. 




12) Rename the event handler to custCreateInfo and set the property as shown below. 



13) Now save your work.

14) Go to Customer form and create a new customer. Here I created a new customer account called “Test-000001”. 





15) Once this customer is created system will give your infolog as shown below.




Hope this will help you to understand the event handler in Microsoft Dynamics AX 2012.

Happy Daxing 

all report deployment for powershell in d 365

all report deployment for powershell in d 365


Open windows powershell in administrator mode.
execute below comments


1.paste the "Set-ExecutionPolicy Unrestricted" instructions
2. then select  "Y" for yes.
3. paste the below instructions


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

how to apply filter in a list page form

how to apply filter in a list page form



List page always extends to its listpage interaction class and if you go there in the respective list page interaction class you will find a method like

public void initializeQuery(Query _query)
{
    QueryBuildDataSource    qbds;
    ProjInvoiceTable        projInvoiceTable;

    if (this.listPage().listPageArgs() &&
             this.listPage().listPageArgs().externalRecord() &&
             this.listPage().listPageArgs().menuItemName() ==  menuitemDisplayStr(ProdTableListPage_Proj) &&
             this.listPage().listPageArgs().externalRecord().TableId == tableNum(ProjInvoiceTable))
    {
        projInvoiceTable = this.listPage().listPageArgs().externalRecord();
        qbds = _query.dataSourceTable(tableNum(ProdTable)).addDataSource(tableNum(ProjTable));
        qbds.relations(true);
        qbds.joinMode(JoinMode::ExistsJoin);
        qbds.addRange(fieldNum(ProjTable,ProjInvoiceProjId)).value(queryValue(ProjInvoiceTable.ProjInvoiceProjId));
    }

    super(_query);
}

here we can add our ranges and values to apply filter on the list page form.

Calculate purchase/sales confirmation GST tax at line level (IGST/CGST/SGST) in AX 2012 R3


Get financial dimension by Recid.

Get financial dimension by Recid.

public static container getFinancialDimensionsByRecId(RecId     _defaultDimension)
{
    DimensionAttributeValueSetStorage    dimStorage;
    Counter                              i;
    container                            ctr;
    ;

    dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        ctr   += [DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name, dimStorage.getDisplayValueByIndex(i)];
    }

    return ctr;
}

Get vendor's and customer's GST number in AX 2012 R3

Hi guys,
IN GST era, It is very common term GST. So here I'm discussing how to get vendor's GST number in X++ AX 2012 R3 and It is very simple to refer below sample code.

 And similarly, you can get Customer's GST number and sometimes we get requirement from client to print warehouse or Company GST number so just refer this below job and modify as per the requirement.

Static void   getVendorGST(AccountNum     _accountNum)
{
    VendTable           vendTable;
    DirPartyTable       dirPartyTable;
    LogisticsLocation   logisticsLocation;
    TaxInformation_IN   taxInformation_IN;

    select vendTable where vendTable.AccountNum == _accountNum
        join dirPartyTable
            where dirPartyTable.RecId == vendTable.Party
        join logisticsLocation
            where logisticsLocation.RecId == dirPartyTable.PrimaryAddressLocation;


    taxInformation_IN   = TaxInformation_IN::findDefaultbyLocation(logisticsLocation.RecId);
    return TaxRegistrationNumbers_IN::find(taxInformation_IN.GSTIN).RegistrationNumber;
}

Happy DAxing......

Reverse string in Dynamics AX.

Hi guys,
Reverse string in Dynamics AX.

static void reverseString(Args _args)
{
    int     i;
    str     temp;
    str     retVar = 'DynamicsAX';
    int     length;
    str     getvalue,RV;
    ;
    length = strLen(retVar);
    for(i=length; i>=1; i--)
    {
        temp =SubStr(retVar,i,1);
        getvalue +=temp;

        // other way with strReverse function
        RV = strReverse(retVar);
    }
    info(RV);
}

Add filter on display method on form control in AX 2012 R3


Get customer email in ax 2012

Get customer email in ax 2012

static void Custermail(Args _args)
{
    LogisticsElectronicAddress          led;
    LogisticsLocation                   ll;
    CustTable                           ct;

    DirPartyLocation     dpl;
    str phone,fax,email,url;
    RecId  RecId;
    ;
    select  ct where ct .AccountNum =='ABC'
    join dpl where ct.Party == dpl.Party
    join led where led.Location == dpl.Location
    && led.IsPrimary == NoYes::Yes
    && led.Type == LogisticsElectronicAddressMethodType::Email;
    {
        email =  led.Locator;
        info(email);
    }
}


Calculate Purchase order confirmation tax details (IGST/CGST/SGST) in AX 2009

Hi guys,

I was struggling  to calculate the GST taxes on purchase order confirmation. Here i am sharing some code to get Taxes details (IGST/CGST/SGST) in AX 2009.

static void GSTTotal(Args _args)
{
    vendPurchOrderJour vendPurchOrderJour;
    ITaxDocument taxDocument;
    ITaxDocumentComponentLineEnumerator componentLineEnumerator;
    ITaxDocumentComponentLine componentLineObject;
    ITaxDocumentMeasureEnumerator measureEnumerator;
    TaxAmount taxAmount,taxValue;
    TaxComponent_IN taxComponent;
    ;
    vendPurchOrderJour = vendPurchOrderJour::findRecId(5637291565); //Need to pass Confirmation journal recid
    taxDocument = TaxBusinessService::getTaxDocumentBySource(vendPurchOrderJour.TableId, vendPurchOrderJour.RecId);

    componentLineEnumerator = taxDocument.componentLines();

    while(componentLineEnumerator.moveNext())
    {
        componentLineObject = componentLineEnumerator.current();

        taxComponent = componentLineObject.metaData().taxComponent();
        taxValue = componentLineObject.getMeasure("Rate").value().value() * 100;
        taxAmount = componentLineObject.getMeasure("Tax Amount").value().value();

        info(strFmt("Component %1 ,Rate %2, Amount%3",taxComponent,taxValue,taxAmount));
    }
}


Happy DAXing.

Friday 1 June 2018

AX7/D365/Operations: Create Details Master pattern form

AX7/D365/Operations: Create Details Master pattern form

Purpose:

The purpose of this document is to demonstrate how we can develop a Details Master form in Dynamics 365 for Operations. While doing so, it also shows how to apply the new form patternsand subpatterns.
Please note that the new Details Master pattern (Dynamics 365 for Operations) obsoletes the older ListPage pattern (AX 2012).

Prerequisites:

  • Access to Dynamics 365 for Operations instance via remote desktop.
  • To be provisioned as an administrator for the instance.
  • Visual Studio project, model, package have been created.
  • Custom table MAKInventRawMaterial has been created in the project.

Business requirement:

Ability to maintain records in a grid and detail view within the same form.

Development:

1. Click Ctrl+Shift+A to add new item to the project.
2. Navigate to User Interface > Form. Give a suitable name, MAKInventRawMaterial.
Form1
3. Drag and drop MAKInventRawMaterial table from the project to the Data Sources node.
Form2
4. Right-click Design node. Click Apply pattern > Details Master.
Form3
5. Once the pattern gets applied, open the Pattern pane to see the missing controls which need to be added to comply with the pattern.
Form4
6. Add the identified missing controls to the Design node in the same order as shown in the pattern tab.
Form5
7. As you can see after adding the required controls the violations have been but still there are some warnings.
8. Navigate to FormGroupControlNavigationList to view its Pattern tab. We still have missing controls for our Navigation List control.
Form6
9. Adding the identified missing controls resolves the pattern issues.
Form7
10. Repeat steps 6 – 9 till all the pattern and subpattern issues have been resolved by adding the missing controls. At the end of the process, you will have a completed form ready to add data source fields to.
11. Add the following field groups to the Details panel from data source table.
Form8DetailsTab
12. Add the AutoReport field group to the Grid control of the Grid panel.
Form9GridTab
13. Navigate to FormCommandButtonControl and set Command property to DetailsView.
Form10CommandButtonDetailsView
14. Navigate to FormGridControl and set Default Action property to the FormCommandButtonControl.
Form11GridDefaultAction
15. Right-click Project > Forms > MAKInventRawMaterial. Click Set as Startup Object.
StartupObject
16. Select project in your Solution Explorer and click Start in Visual Studio.
17. You should be able to see your form in action in the browser.
18. Grid view.
Form12GridView
19. Details view.
Form13DetailsView

Labels

#veryusefulcode (1) AIF (8) AOT Maps (1) Args (1) Ax 2009 Reports (2) AX 2012 navigation (1) Ax 2012 Interview Questions (1) AX 7 (2) AX Architecture (1) Ax Backup (1) AX Workflow (2) AX2012 (1) AX2012 R2 (1) Ax2012R3 (1) AX2012R3 Dynamics Connector Step by Step Installation and Configuration (1) AX2012R3 EP Step by Step Installation and Configuration EP R3 (1) AX2012R3 HelpServer Step by Step Installation and Configuration (1) AX2012R3 Rapid Start Connector Step by Step Installation and Configuration (1) AX2012R3 Report Server and Analysis Server Step by Step Installation and Configuration (1) AX7 (1) Best practices (1) Blocking user to enter (1) Collection Classes (1) Container (1) D365FO (3) Data Migration Frame Work ax 2012R3 (1) Deleting duplicate Record from Table – Ax2012 (1) Delivery due date notification workflow in Ax 2012 (1) Development Steps EP (1) Dimensions (1) DIXF (1) DMF in Ax 2012 R3 (1) Dynamics Ax 2012 Interview Questions (1) DYNAMICS AX 2012 INTERVIEW QUESTIONS PART 2 (1) DYNAMICS AX 7 (1) EDT relation Migration Tool (1) EP AX 2012 (1) Ep Lookup (1) Error (1) Event Handler (1) F5 (1) File Handling (4) Filter on AX2012 Listpage (1) filtering (2) financial dimensions in AX 2012 (3) form (1) images (1) Installation and Configration (4) Installation and Configuration (11) Installation of Management Reporter 2012 for AX 2012 (1) Interaction class in ax 2012 (1) Interview Question (1) Interview Questions For Ax 2012 (1) Invent DIm (1) Jobs (2) license (1) List page and form menuitem enable code (1) Methods (1) microsoft Dynamics AX 365FO (1) Number Sequence Generation – AX 2012 (5) Number Sequence2012 (1) OLTP-OLAP (1) Passing Args (1) Passing form caller and menu item caller in ax 2012 (1) Passing Multiple Records Args (1) Posting in Ax 2012 (1) POSTING PURCHASE ORDER (1) Query (1) Query Filter Form (2) Query Ranges in X++ (1) Question and Answer (1) Report (1) Reports Controller class (1) RLS in ax 2009 (1) SALES ORDER IMPORT/EXPORT FRAMEWORK BY DMF (1) Security (1) security roles (1) Security Sysqueryrangeutil (1) Sharepoint 2016 (1) SQL SERVER (1) SSRS (2) SSRS Reports Controller class (2) Table collections & Virtual company (1) Time (1) TIPS AND TRICKS (1) Web service AIF (3) Web Services on IIS (AIF) Step by Step Installation and Configuration (1) workflow ax2012 (1) Workflow installation (1) Workflow Method (3) X++ (1)