Search This Blog

Tuesday 13 August 2013

Modifying the Form DataSource Query in Microsoft Dynamics AX 2012

Hi its quite easy  in Microsoft Dynamics AX to modify the query of the form on some scenarios.

Like there is the scenario in which i want to show all number of positions when user click the assign button and shows only those positions which have cost element assigned  when the user clicks the update button.

Just consider the scenario when the user clicks the assign button.
The below form is open containing all the forecast positions inside the grid.















And when the user click the update button only those positions will be shown which have cost element assigned.

As you can see in the image below.














This change is just because of we have override the datasource init method and modified the query.

Just go to the form datasource on which you want to modify the  query in my case i have hcmpositionforecast datasource.

Just go to the its datasource methods and than right click and than override the init method.

inside that method write the form datasource query and than modify it based on your scenario.As you can see this in the image below.













Thanks

Muhammad Zahid.

Saturday 22 June 2013

Using RecordInsertedList To Insert Multiple Records In Single Database Transaction

RecordInsertList Class:

The RecordInsertList class provides array insert capabilities in the kernel.   

RecordInsertList Class is really very helpfull class to increase the perfomance  while inserting  the bulk records.

Like there is a scenario where you are inserting the bulk records into the table using the while select one by one.In this case if there is a scenario where you are trying to enter the 100 records one by one than its means that you are trying to hit the database 100 times.

Now by the help of the RecordInsertList Class.We can easily insert these 100 records in single database trip.

Below is the example of how can we use the RecordInsertListClass:


As you can see in the above image that I have Declare the RecordInsertList object and than I have assign the values to the table buffer and than I am going to add the table buffer to the RecordInsertList object and one all buffers are added to the list I am going to insert them into the database.

This was all from my side ralated to the RecordInsertList.I hope you like that.

Below is the link of msdn for more detail explanation about that:

RecordInsertList

Optimizing Record Inserts

Thanks

Muhammad Zahid

Thursday 30 May 2013

Adding Lookup with custom range on Forms In Microsoft Dynamics Ax 2012

Its quit easy in Microsoft Dynamics AX 2012 to create the lookups.

Lookups are basically the drop down list through which we are selecting the value and then setting the value behind that field.

You can see in the below image on what lookups are and how they work.


  In the above image when we click the add button or click the purpose field then the lookup is open.You can make these kind of lookups in your own forms.

Below are the steps for making the custom lookup with your define ranges.

 Step 1:

First on the form -> DataSource right click the field on which you are making the lookup and than select the override method lookupRefrence().

As you can see in the below image.














Now you can see whats inside that method.









Actually in the above code I am calling the another method that I write on the table level.Inside that method I have make the logic of the lookup.

In the below image you can see the logic of that method for making the lookup.









Basically in that Method I have made the query which fetches the record based on our criteria and than we make lookup on the based on the fetched data and than return it to the form.From where it was called.

That was all from my side related to the custom lookups.

I have also see a very good link related to the lookups.You can also check this.

Custom Lookups 

If you still have any questions related to the custom lookups than feel free to post it on my blog.

Thanks

Muhammad Zahid

Thursday 9 May 2013

Simple Use of Compile Forward In Microsoft Dynamics AX 2012

Some times when we modified the definition of the method like increasing or decreasing the number of parameters and than in other code when we call that method its gives us error like "wrong number of parameters or something like that"


As you can see that in the below image.











Now some times these errors are not belongs to your code.

To fix these kind of issues you just have to go to the class that contains the definition of the method that you are calling and than right click that class than click compile Forward.

as you can see in the image below.























Now after doing this the error will not come in your code that calling the method of that class.As you can see in the below image







By the help of Compile Forward we can resolve these kind of errors.

I hope you like my post.

Thanks

Muhammad Zahid.

Friday 5 April 2013

Business Operation Framework In Microsoft Dynamics AX 2012

Business Operation Framework:

The Business Operation Framework service is one of the system services exposed by Microsoft Dynamics AX and that adheres to the Windows Communication Foundation (WCF) protocols and standards.Following are the features BOF.

  •  Allows menu-driven execution or batch execution of services.
  •  Calls services in synchronous or asynchronous mode.
  •  Automatically creates a customizable UI based on the data contract.
  •  Encapsulates code to operate on the appropriate tier (prompting on the client tier, and business logic on the server tier). 
  • You can schedule the batch job by the help for batch execution at the specific intervals.

Previously we uses the RunBase Dialog but its now obsolete and we now uses the Business Operation Framework Service.Its basically the service that runs behind the AX.

 Steps For Using the Business Operation Framework:

Below are the some steps that are required for using the Business Operation Framework:

Step 1:

First we will create our  contract class in which we will define our parm methods for the variables that are input by the user.

In my scenario I will take two integer from the user and than show the addition of these two numbers on the info box and  one more thing I will show the query  dialog box  to the user and than print the selected values from the query dialog box on the infobox.

First we will create our Data Contract class as you can see in the image below.
















In the above code I have added the DataContractAttribute above the contract class that is usefull for the creation of the Contract Class and the second attribute is basically optional in that attribute I am basically adding the group some thing like that.

Now inside the class declaration I have declare the input variables that will be input by the user and use inside the parm methods.

Below are the images of the parm methods inside the contract class.


























As you can see the above images are of the parm methods of  the Contract Class and that we use for the inputs by the user.

As you can see in the above images that there are some attributes above each method.I will explain one by one about each attribute.

 DataMemberAttribute is the attribute that is required before each DataContract method.

SysOperationLabelAttribute(literalStr('First Number')) is basically the attribute that is
use for the label to show first number before the text box.

 SysOperationHelpTextAttribute(literalStr('Enter First Number')),This is basically the help text i,e that is shown when we move mouse on the textbox.

SysOperationDisplayOrderAttribute('0'),This show the display order of that attribute.

SysOperationGroupMemberAttribute('Numbers') this shows that this attribute is related to the  group 'numbers'.

 AifQueryTypeAttribute('_query', queryStr('CustBaseData')) This is the attribute use when we are making the query dialog box.So we need to define which query we are going to use.In my case I am using the CustBaseData Query.

Step 2:

Now after creating the contract class we need to create the Service Class.

Just create the service class as we make our normal class and than create the method in that class and than pass the contract class in the parameters of that method and than attach the attribute i.e "SysEntryPointAttribute" on the method.Basically this method is use to operate the user input.

Now you can see the code in the image below of that operation method of service class.

















As you can see in the above image that what i am doing in the operation method.I am just adding the two numbers that are input by the user and than printing them on the infolog and one more thing I am getting the values from query dialog box and than printing them on the infolog.

Note:we need to add the [SysEntryPointAttribute] on the top of the method of the service class.

Step 3:

Now in the step 3 we need to create our service.

Just go to the Service node inside the AOT and than create new service by right click than select new service and than in the property of that newly created service just set the name of the service class that we have created early in the step 2.

As you can see in the image below.




















 Step 4:

Now in the step 4 we need to create the service group.

Now go into the Aot->Servicegroups -> Axclient  and than right click and than select  new service node reference and than in the property of that newly created service group set the name of the service that we created in step 3.

As you can see in th below image.























Now right click that zahidservicegroup and than right click and than select the deploy to deploy that service group.

Step 5:

Now in the final step we need to create the menuitem.

Just Create the action type menuitem and than in the property sheet of that menu item set the object type = class and than object = "SysOperationServiceController"
Parameters = "zahidservice.startoperation"

As you can see in the below image.


















Basically sysoperationservicecontroller is the framework class that builds the UI on the basis of our contract class.

Note: you can create your own UI builder by extending your UI builder class from the sysoperationservicecontroller class.

Now I will run the menu item and than show you the output.















Now i will click the select button of the query dialog box and than select the values of the queries.

You can see that in the image below.




















Now when I press the ok button the two values will be selected as you can see in the image below

Note: I am using the CustBaseData Query in the query dialog box.




















Now when I press the ok button the sum of two numbers and the query will  be printed in the info box.

as you can see in the image below.

















This was all from my side related to the business operation framework.In the next post I will cover the Advanced topics of the Business Operation Framework.

I hope you like that post.If you have any questions than feel free to ask

Thanks

Muhammad Zahid.

Tuesday 26 February 2013

Creating Vacation Appointment for your Calendar and seeing others Appointment In Outlook

Its quit easy to setup a PTO Appointment or sum other Appointment to create in outlook and that will be easily available to view for others when they are trying to create meeting with that employ.

Below are the some easy steps for Creating an Appointment.


Step 1:

First of all go to the calender of your outlook and than select the Calender and than click the new appointment button as you can see in the image below.
















Now When you click the new appointment a new wizard will open where you have to enter the subject and than timing of  appointment and than select the show as option as if you were busy or out of office in that time span and than click and than click the save and close button.Your Appointment will be created and others can easily see this while creating the  meeting request if your appointment is not set to private.

You can see all of these in the image below.










Now your appointment will be showing in the calendar as you can see in the image below

















Now this was all for creating Appointment.
Now second thing I want to show you is that  while creating meeting request with others you can also see that if others are busy or on out of office or not available in that timing slot.

Below are the steps for checking the appointment of other person.

Just click the new appoitnent as you did earlier a new wizard will open and than click the scheduling assistant button as you can see in the below image.  











Now a new wizard will open and where you can enter the name of  the employee and check that whether this person is available in that timing slot or not.As you can see in the below image.

























As you can see in the above image that abubakar is not available on that timing slot because he is out of office in that time.

This was all for creating the appointment and checking others are available or not in the timing slot.

I hope you like that post

Thanks

Muhammad Zahid.

Thursday 21 February 2013

Eventing Framework In Microsoft Dynamics AX 2012 Part 2

Now In this Post I will guide you how to create Events.

We have basically already discuss that what events are.Now In Microsoft Dynamics AX two terminologies are used these are.

1.Pre Events.

2.Post Events.

Pre Events are those that called before the method and post events are those that are called after the method.

Now I will show you the Scenario I can we use Pre and Post Events.

Below are the some steps for creating and using the events.

Step 1:

First we will create the simple table with two fields i.e  as you can see this in the image below.

 Step 2:

Now we will create the SimpleListDetail Form

As you already know how to create a form.

Now after creating the SimpleListDetailsForm drag the table that we have created earlier on the datasource node of that SimpleListDetailForm.and from datasource drag the fields to the details header and grid node of the design node.

As you can see in the image below.


























Run that form it should be exactly like below form.














Step 3:

Now will create a method on the table i,e assignned to to this form.The is validatewrite method and before and after that method we will create events.What I am trying to say is one event will fire before the execution of that method and one event will fire after the execution of that methods.

First we will create the method as you can see in the image  below

























Step 4:

After Creating the method we will assign pre and post events to it.

Just right click the method and than select the new event handler subcription.

As you can see in the below image.

























Now when you create the new event handler just go into the properties of the that eventhandler and than set the properties to the " Called When" =  Pre and than "Class name" = name of the class and "method" = name of the method that will be called before the execution of that method.

As you can see in the image below.
















Now inside the zahidpre method I am just showing the message inside the info box that the pre method is called.

Now its quit easy to create this event handler method i.e zahidpre.

Just right click the class and than select new->pre-post-eventhandler.

As you can see in the image below.




















An Event Handler will be created as you can see in the image below.











Now repeat the step 4 for the Post Event Handler.Only one thing you should do is when creating the Eventhandler on table just set its property "called when" = Post.

As you can see in the image below.












Now I will show you the demo that how pre and post event handlers are run when we run the form.

As you already know that inside the pre event handler I am showing the info message that "Pre is called" and same thing for the post event handler that I am showing that the "Post is called" and inside the validate write method I am showing that the "This called form the validate write method".

Now I will run the form and than insert the record and during the insertion of the record first pre event  will be call and than the validate method will be call and than the post event will be called.

 As you can see in the above form that I have inserted the record  and when I click the new button or close the form the data that I have write will going to insert into the record and that pre event will call and than the validate write method will call and than post event will call.

As you can see the messages of the info box inside the below image.



 
















Now This was all related to the Event Framework part.

I hope you like that post.If you guys have any issues than feel free to comment or contact me :) :)

If you want to go to eventing framework part 1 post than click on the link below.

Eventing Framework Part 1

Thanks

Muhammad Zahid.