Tuesday, May 1, 2018

How to write a display method in extensions (D365)

Requirement is to display a column from InventTable on Movement Journal lines form based on the selected item.

1. Create a new class and give a name, best practice is to give a name of the object with extension keyword





2. Once class is created, make sure you are using proper syntax and namespaces as below and also write the display method based on your requirement -



3. Compile the class.
4. Now find the 'InventJournalMovement' form in AOT and create an Extension





5. Then open the form and create a column as per your requirement.








6 . After create a new column, right on the column and select properties and then select the data source and data method which we have created in a final class.




7 . Build the solution. Now we should be able to see that column in Movement journal lines form



Tags: #DisplayMethods , #Extensions, #X++, #D365FO

Wednesday, April 25, 2018

How to override a clicked method of a button in a form Extension D365

Requirement is to add a button on CustInvoiceJour form and override the clicked method, so I would be creating an extension of that form and will add button there.

1. Create extension of 'CustInvoiceJour' form


2. Open extension of that form from the solution explorer and add a button



3. We have added a button, now we have to perform some operations on click of that button. And for that we need to write the 'OnClicked' event. In order to do that, expand the 'Event's under that control and right click on 'onClicked' event and select 'Copy Event Handler Method'

4. 'OnClicked' event handler is copied and now you can paste as a method in any of your custom class or you can create a new class. I am using one of my custom classes.

5. Now the question is, how we will get the selected record on that form or how would we get the form data source, if you take a look of this above method, you will seen we have a formContol as a parameter and by using that we can get the form data source and selected records.


After getting the table buffer and form data source, we can perform other operations.

Tags : X++ , D365, Form extensions, Events, OnClicked

Wednesday, April 18, 2018

Add controls run time and override the method in D356 (X++)

Here I will be explaining, how to create buttons run time and override the clicked method.

We would be creating buttons run time based on the setup companies in some custom table, Like I have table called 'DemoCompanyList' and that table has 3 companies setup

1. USMF
2. USMG
3. IND

Lets create a form and give a name 'DemoRunTimeControl' and then we can apply the pattern based on our requirement and then add Action Pane - Button Group - Menu Button(control name - ButtonHeaderInquiry), change the AutoDeclaration property to 'Yes' for this control.

Form Methods - 


init() - To get the list of companies and call method addRunTimeButtons()

addRunTimeButton() - In this method we will add buttons to menu button and also register the clicked method so that when we click on those buttons, it should the written clicked method.

RunTimeButton_clicked() - In this method we will opening the custInvoiceJour menu item based on the clicked button.


[Form]
public class DemoRunTimeControl extends FormRun
{
    Map                 buttonCompany;
   
    public void init()
    {
        container   companies;
        counter     i;

        super();

        buttonCompany = new Map(Types::Integer, Types::String);

        companies = DemoCompanyList::findCompanyList(); // Find company list will return the list of the companies

        for (i = 1; i <= conLen(companies); i++)
        {
            element.addRunTimeButton(conPeek(companies, i)); //addRunTimeButtons will add buttons based on the company setup
        }
    }

    private void addRunTimeButtons(DataAreaId _dataAreaId = #emptyString)
    {
        FormButtonControl           runTimeControl;
        #define.runTimeCtrl         ('DemoRunTimeButton')

        runTimeControl = ButtonHeaderInquiry.addControl(FormControlType::Button, #runTimeCtrl + _dataAreaId);
        //Invoice (%1)
        runTimeControl.text(strfmt("Customer Invoice (%1)", _dataAreaId));
        runTimeControl.registerOverrideMethod(methodStr(FormButtonControl, clicked), formMethodStr(DemoRunTimeControl, 'RunTimeButton_clicked'), element);
        buttonCompany.insert(runTimeControl.id(), _dataAreaId);
    }

    public void RunTimeButton_clicked(FormButtonControl _formButtonControl)
    {
        //Set the local control to the actual control that is calling the method.
        _formButtonControl = this.controlCallingMethod();
        CompanyId company;

        company = buttonCompany.lookup(_formButtonControl.id());

        if (company)
        {
            changecompany (company)
            {
                //Open invoice journal in specific company
                new MenuFunction(MenuItemDisplayStr(CustInvoiceJour),MenuItemType::Display).run();
            }
        }

    }

}



When you will click on first button, system will open customer invoice journals form in USMF company and the same way if you click on IND one, system will open journals from IND company.





Thursday, September 21, 2017

Microsoft Flows - How to create a very simple flow

Automate tasks by integrating your favorite apps with Microsoft Flow. Make repetitive tasks easy with workflow automation.

Here are steps to create a flow-

1. Open a web browser and open URL https://us.flow.microsoft.com/en-us/


2. Click on 'My flows' and then hit '+ click from blank'


3. It will open a page as below and then we should select a trigger, I have selected 'When a new mail arrives' for this demo



4. Give the name of your flow and also we can put multiple criteria(s)


5.  Then go for  next step, you will get two options
  1. Add an action
  2. Add a condition
I have selected 'Add an action'



6. We have multiple actions to select, I have selected 'Notifications' for this demo


7.  You will get two options

  1. Send me a mobile notifications (Mobile App required)
  2. Send me a email notifications

I have a selected 'send me a mobile notifications'


8.  We need to select content for notifications. And also I have selected criteria 'FROM'  'ajitax@outlook.com', that means I'll be notified if I get an email from this email address only.

After selecting values, hit 'create flow' and done.



9. You can see that flow under 'My Flows' and also can review run history.  I already sent an email from my 'ajitax@outlook.com' email id to my work id which is associated with Microsoft Flow.


10. As soon as I received email from this particular email id (ajitax@outlook.com), flow notification showed up in my mobile.














Vendor Invoice processes at one place in D365

                           Vendor Invoice Entry


Dynamics 365 has one place for all your vendor invoices related need -



Here you can create new invoices\invoice journals and also can view all non-invoiced Purchase orders here.



And even we can create and view global invoice journals


Wednesday, September 20, 2017

TF400813: Resource not available for anonymous access. Client authentication required.

I was trying setting up TFS online (VSO) from my AX 2012 R3 instance


And got this below error -


I am using VS 2013 and Team Explorer 2010

Resolution -

Install Visual Studio 2010 SP1 Team Foundation Server Compatibility GDR from


Restart AOS and try. If that doesn't work, try after restarting Dev itself.


Monday, September 18, 2017

How to write a job (Runnable class) in Dynamics 365

                    Steps to create a Job\Runnable class in D365

Step 1 - Open a new project in Visual Studio -



Step 2 - Select the 'Dynamics 365' as a template and enter the name of the project -



Step 3 - Solution Explorer would be open with your new project



Step 4 - Right click on your project and select Add-> New Item


Step 5 - Select the 'Runnable class(Job)' from the list -



Step 6 -  As soon as you select 'Runnable class(job)', it will open below window -


Step 7 - Just added info to print the 'Hello World' :)



Step 8 - Save the changes and right click on your project and click on 'Set as Startup Project'


Step 9 - Now start your project by clicking start button as shown below -


Step 10 - Once you start, it will open the browser with your result.