Showing posts with label Query. Show all posts
Showing posts with label Query. Show all posts

Thursday, December 29, 2011

WALKTHROUGH - Creating Fact Boxes in AX 2012 - PART III

In my last post (http://axwonders.blogspot.com/2011/12/walkthrough-creating-fact-boxes-in-ax_28.html ), we created 3 EDT’s, 4 tables and created the relationships we needed to hold the Auto Rental data.  In this short post we are going to talk about primary indexes, and then we will create one for the Eduardo_CustCarTable.  In addition, we are going to learn a little bit more about Form’s Parts in AX 2012 before jumping into creating the user interface forms for the Auto Rental data.

Indexes
For detailed information about indexes you can read the following: http://axwonders.blogspot.com/2011/11/indexes-in-microsoft-dynamics-ax.html
In a nutshell, we can say that a primary key is one or more columns that uniquely identify one record in a table from all the other records.  A primary index is a unique index for a table that defines the primary key for that table. To set an index as a unique index, set the index property Allow Duplicates to No. This is the same idea as creating a MS SQL table primary key (Check the following post for more info about this http://blog.sqlauthority.com/2008/09/08/sql-server-%E2%80%93-2008-creating-primary-key-foreign-key-and-default-constraint/).
NOTE: When a primary index is not specified, AX uses a Surrogate Key as the primary index. This key is the RecId field and, if the table is saved per company, the DataAreaId. The surrogate key is used on many relations between tables.
To set the primary index on a table, open the property sheet for the table. The PrimaryIndex property allows any unique index with a key that is mandatory and cannot be edited.

1.       In the AOT, locate the Eduardo_CustCarTable table.


2.       In the property sheet for the table, set the PrimaryIndex property on the table to RentalIdx






Parts
So, what are Parts? [From Microsoft - http://msdn.microsoft.com/en-us/library/gg844683.aspx ]A Part is a specialized type of control you use to retrieve and show a collection of data. A part specifies how to retrieve the data that appears in the FactBox pane of a form, the preview pane of a list page, or the enhanced preview of a control. You use parts to provide information related to a record that appears in a form…

…To create or modify a part, you use the properties of that part to describe how to retrieve and show data. For example, you use a part property to specify the data source for the part. Typically, you use a query as the data source for a part. You also use properties to specify the data fields that show when the part appears as a FactBox on a form.
Then a FactBox is the collection of data that appears on the form, which is based on a Part.  In addition, a FactBox always represents a single part, and if we want to modify a FactBox, we must modify the underlying part.
In AX 2012, a part is defined by using metadata and each part we create extends a common metadata model for parts. Further, one of the best advantages of the Part metadata model is that enables us to create parts that can appear in both the client and Enterprise Portal (EP).
Parts also allow us to represent data through cues in AX 2012. To show a cue in the FactBox pane of a form, you add the cue to a cue group part. A cue group is a type of part that contains one or more cues, and these can be created as a cue group that can appear in forms for both the client and EP, which can be used to add information to a role center page.
In my next and last post about this topic, we will create the user forms needed to display the Auto Rental data. In addition, we will create menu items, and of course a FactBox to display Auto Rental information related to a customer.


Take Care!

Monday, August 1, 2011

Create Electronic Payment Format - AX 2009

Electronic payments are being used heavily today. It is importnat to understand how these work and how to implement them as they save lots of time and even more paperwork. In addition, AX 2009 provides some out-of-the-box payment templates, but they are not very felxible and very often we need to create our own.

Now the good thing about creating our own is that we can inherit from two base classes. (1) VendOutPaym and (2) VendOutPaymRecord.

VendOutPaym is ussually used to create the header and closing records of a payment file. On the other hand, VendOutPaymRecord is used to create the the lines records of the payment file. So, if we have a payment journal (AP > Journals > Payments> Payment Journal) with 10 lines, we should see only one header line, (in my case) only one Bank line (after header), 10 line records (Payment journal lines) and one closing line with totals, got the idea?

So, we would have to create two classes. One to write the header and closing records and one to write the journal lines, ok?

Here is the first class to write header and closing records. Because in my file the empey spaces needed to be filled with only 0's, I created a method that's called getProcessedStr that takes a string and an integer. The string is the actual value that will be written into the file but needs extra 0's. The int is the total lenght of this record in the text file.


Wednesday, July 27, 2011

strRem Function - Delete a Character from String - AX 2009

The following code searches a specified string character and deletes it. The cool thing about this function is that it is case sensitive.


str strRem(str text1, str text2)
text1  The string from which to remove characters.
text2 The characters to exclude from the output string.

For example:

strRem("MynameIs","is"); //Returns the string "MynameI".

Thursday, March 3, 2011

Filter the Activity Form contact to only existing records on a Business Relationship by creating a Lookup Dynamically- AX 2009

Today a user came to me and asked me if I would be able to show only the contacts related to a Business Relationship when choosing a contact in the Activity form.


The following is the form:



 The original setup would show all the contacts available table wise. This was a problem for the users as it will take a lot of time for them to find the right contact.