AIF Services Ax2012




AIF Services In few steps.




Today we learn how to create an AIF service

Step 1
Create a Table and add the below fields.
Fields:
  • Name
  • Phone

Screenshot reference:






Step 2
Create Two classes
  • Student Contract 
  • Student Service

Screenshot reference:





Step 3
Open Student Contract  Class Defines Variable and Create Get Set Method

Screenshot reference:







Step 4
Open Student Service Class

Screenshot reference:



In your student service class create two method
  • Insert Student
  • Get Student

Screenshot reference:



Get Student

Screenshot reference:




Step 5
Set your Student Service Class Run On server

Screenshot reference:




Step 6
Right Click on your project root node and select Service from the Submenu

Screenshot reference:




Step 7
Set the class reference on service properties

Screenshot reference:




Step 8
Then Expend the Service and right-click on the operation and select Add Operation

Screenshot reference:


Step 9
A window will appear now select the method you want to expose to the client in my case I am going to select both methods

Screenshot reference:



Step 10
Right-click on your project and Add a service group

Screenshot reference:




Step 11
Now drag and drop your service into the service group and compile the complete project. after compile right click on the service group and deploy the service group. below window will with deploy result

Screenshot reference:





Step 12
System administration/Area page. 

Screenshot reference:



From the below screen you can find your service External URL

Screenshot reference:





How to Test Service

Step 1
Open Visual Studio
Create a Console application
Step 2
Add Service Reference
Screenshot reference:






Step 3
Add following Code
Screenshot reference:




Step 4
Run Application. Hope the application will be working fine if you follow every step properly. :)

Screenshot reference:

Please feel free to contact me if you are facing any issues during the implementation of this blog.


Form Look Up



Form Look Up

Today, we Learn how to create Form Look Up
Step: 1
Create a Project and Add two forms.




Step :2
  • Add HCMWORKER table in SL_LookUp_Form Data Source.
  • Add Grid and Drag and Drop the two fields on the grid
Step :3
Set Personnel Number field Property : set as Auto Declaration to YES


Step :4
Now Compile the complete project then run the form.




Step :5
Now right click on Design node(not Designs) and set style property to LookUp.



Compile and Run again Form will look like the below image.



Step :6
Now override the init method of SL_Lookup_Form .



copy paste the below code.



Step:7
Now Select SL_First_Form
Create a Method with name of CustomLookup and copy paste the below code.




Step: 8
  • Add StringEdit Control in the Design.
  • After adding the StringEdit Control override the lookup method.
  • Copy paste the below code.


Step :9
Compile project and run SL_First_Form




Please feel free to contact me if you are facing any issue during implementation of this blog.










How to find or create default Dimension from X++ in AX 2012


How to find or create default Dimension from X++ in AX 2012


Following is the code you can use to find or create dimension in AX 2012


static DimensionDefault generateDefaultDimension(container _attr, container _value, boolean _createIfNotFound = true)
    {
        DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
        DimensionDefault result;
        int i;
        DimensionAttribute dimensionAttribute;
        DimensionAttributeValue dimensionAttributeValue;
        //_attr is dimension name in table DimensionAttribute
        container conAttr = _attr;
        container conValue = _value;
        str dimValue;

        for (i = 1; i <= conLen(conAttr); i++)
        {
            dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

            if (dimensionAttribute.RecId == 0)
            {
                continue;
            }

            dimValue = conPeek(conValue,i);

            if (dimValue != "")
            {
                // _createIfNotFound is "true". A dimensionAttributeValue record will be created if not found.
                dimensionAttributeValue=
                dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,_createIfNotFound);

                // Add the dimensionAttibuteValue to the default dimension
                valueSetStorage.addItem(dimensionAttributeValue);
            }
        }
        result = valueSetStorage.save();
        return result;
    }

Read Excel file using OpenXMLSDK Dynamics 365(AX-7)


Read Excel file using OpenXMLSDK Dynamics 365(AX-7)

Following is code you can use to read Excel using Open XML.






using DocumentFormat.OpenXml;
using System;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;

public class SLAX7_ImportClass
{

public void testRun()
{
OXMLSpreadsheetDocument_RU document = OXMLSpreadsheetDocument_RU::construct("C:\\AX\\Test.xlsx");
OXMLWorkBook_RU workbook = OXMLWorkBook_RU::construct(document);

OXMLWorksheet_RU worksheet = workbook.getWorksheet(1);

OXMLRow_RU row = worksheet.row(1);
OXMLCell_RU cell = Row.cell(1);
Global::info(strFmt('%1',cell.getValue()));

}

}

Process Data packages Life Cycle Services


Process Data packages


Following are the steps to create Process data packages using LCS and apply to your environment.


Step-1 Navigate to Data Management Workspace and click on Export Tile.

Reference screenshot




Step-2 select any entity and export the data in Excel. Which we will use in the next step. then click on download the package.

Reference screenshot




Step-3 Now login to LCS and navigate to Assets library and click on the data packages Tab.

Step-4 Add the New data package and upload the package. which we downloaded in step-2. 

Reference screenshot




Step-5 Now click on Process Data Packages and click on the + icon to add a new PDP.

Step-6 Pre-requisite Business Process required to create Process Data Package.

Step-7 Click on + Icon to add Process data packages. Popup will appear fill out the required fields and click on confirm.


Reference screenshot




Step-8 New screen will appear in 3 to 4 seconds. 

Step-9 Select the business process (Step-6) and click on Next.

Reference screenshot





Step-10 Now click on select data packages and select your required package from the popup and click confirm.

Reference screenshot





Step-11 Add the package dependency if any. in my case there is no dependency. so I skipped this step and click on next for the last step of this wizard.

Reference screenshot



Step-12 Now select your business process and click on data packages and save the complete process.

Reference screenshot



Step-13 Navigate to the Assets library again and click on the Process data packages Tab.

Step-14 Select your required Process and click on consume icon.

Reference screenshot


Step-15 Click on consume new process data packages.

Reference screenshot





Step-16 fill the required fields like the below screenshot and click on Create.

Reference screenshot



 Step-17 Now click on newly created records to open the PDP in the new window.

Reference screenshot



Step-18 New window has 3 following steps.
  1. Review
  2. Review & Approval
  3. Apply Data package.

Step-19 select the process node and Mark process as reviewed. In my case, I have marked the complete process as reviewed.

Reference screenshot



Step-20 On the 2nd step mark as approved this operation will navigate to you on the new screen.

Step-21 Click on approve icon to change the status from Not Started to Approve

Reference screenshot



Step-21  If you want to change the data package click on upload data package else skip this step.

 Reference screenshot



Step-22 Click on Apply icon to start the process. To perform this activity you should have Admin (tenant user on) your desired environment.

Step-23 Select the company from the popup and click on apply.

Reference screenshot


Step-24 Once the process starts, it will change the status to in-progress then complete if everything works fine.

Reference screenshot





Please feel free to contact me if you are facing any issues during the implementation of this blog. 



Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...