RSS

Tag Archives: Microsoft

Image

Using table method on Document Handling generation via COM

Hi Guys,

I just got a chance to work on creating document using word or excel template. in Dynamics AX we have a very good feature in document handling Create Word document via COM or Create Microsoft Office Excel worksheet via COM. Using these features we can create word or excel template, and create and attached the document to the record filling the template fields from the table record.

I don’t want to explain how to setup this type of document, you can read the blow link for that,

http://technet.microsoft.com/EN-US/library/aa548928.aspx

The problem arises when i try to use the the field which is not on the table or don’t have a direct relation with the table i have setup. For example, i have used the SMAServiceOrderTable and i have requirement to fill the “Payment term” on the template, which is on the ProjInvoiceTable. Which has a relation with SMAServiceOrderTable through ProjTable (SMAServiceOrderTable->ProjTabe->ProjInvoiceTable).

The solution i think for this problem is to customize Document handling feature to have the provision of using the method of the table instead of just the fields.

So the problem solved, I added a field on the “DocuField” table for methodName modify some classes. I have provided the link for the XPO for that.

XPO,

https://docs.google.com/file/d/0B7b9JMHh3V2eYnpaSldVNTg0TFE/edit?usp=sharing

I have modified the DocuField table so that method name of the table can be specified.

Then i make changes on the \Classes\DocuActionTrans\insertField  method, to get the value from method using DictTable class.
Thanks for Reading.

Advertisements
 

Tags: , , , , ,

Different styles of Tabs in AX 2012

User Experience in Dynamics AX 2012 has really been improved and we have some more stylish way of designing the form. In AX 2012 the tabs are now can have different styles. In 2009 we have Tabs displayed in horizontal, see the below image.



This style is still available in AX2012. Now, take a look other styles of tab in AX2012

 

 

Fast Tabs

Fast tab is a new style of tabs, in this style the tabs can be expanded and collapsed. This style is useful if user wants to view the information from two or more tabs at the same time.

 

Vertical Tabs

In vertical tab style, the tabs are displayed vertically on left side. This style can be used in parameters form of modules.

Index Tab

Index tabs are used for line details information. The tabs are displayed at the bottom of the form/group. See the below screen shot.

So the tabs are now more stylish in AX2012. But how can we change the style? It looks that we need to a lot of work. However, believe me it is a piece of cake. The styles can be change by just setting the “Style”  property of Tab.

Isn’t it simple? Keep reading and visiting my blog and wait for more interesting things of AX2012.

 
Leave a comment

Posted by on August 18, 2011 in AX, Dynamics, Forms, Microsoft

 

Tags: , , , ,

Dynamics AX 2012 EP Session video

Enterprise Portal is one of the most attractive feature of Dynamics AX 2012. Enterprise Portal for Microsoft Dynamics AX provides a Web-based application framework that allows for users to interact with data in Microsoft Dynamics AX through a Web browser.
I shared this video to have the understanding of the development of EP in AX 2012.

see the video by clicking the below link.

http://vimeo.com/26902748

 

Thanks & Regards.

 

 

Tags: , , , , , ,

Delete Action

Cascade

A cascading delete action will delete all records in the related table, where the foreign key is equivalent to the primary key of the current table. That is, deleting the parent record will also delete the child record(s) in the related table. This cascading will take place whether the deletion is performed in code or directly by a user through the user interface.

Restricted

A restricting delete action will raise an error message if the user tries to delete a record, where records exist in the related table where the foreign key is equivalent to the primary key of the current table. This error will only appear if the deletion is performed through the user interface. A deletion from X++ code will be allowed to proceed and will not be cascaded to the related table. In this case the programmer should call .validateDelete() themselves prior to the call to .delete()

Cascade + Restricted

The delete action performs a restricted, if the record of the table will be deleted directly and performs a cascade, if the record of the table will be deleted through a cascade delete action of a other table.

 

Thanks for reading. keep visiting and giving feedback.

 
Leave a comment

Posted by on February 7, 2011 in AX, Basics, X++

 

Tags: , , , ,

Exceptions Inside Transactions

When an exception is thrown inside a transaction, the transaction is automatically aborted (a ttsabort operation occurs). This applies both for exceptions thrown manually and for exceptions thrown by the system.

If an exception is thrown inside a ttsBegin/ttsCommit block, it will be caught by the first matching catchlist that is outside the transaction block. If there is a catch block within the ttsBegin/ttsCommit, it will be ignored

 

Example

Example  shows how an exception in a ttsBegin/ttsCommit block is caught by the first catchlist outside the block rather than by the catch within the ttsBegin/ttsCommit block. If you run this code, “outside tts” will be printed before an Infolog displays “Message”.

try

{

ttsbegin;

try

{

throw error(“Message”);

}

catch

{

print “not here”;

pause;

}

ttscommit;

}

catch

{

print “outside tts”;

pause;

}

 

Source: http://msdn.microsoft.com/en-us/library/aa893385(AX.10).aspx

 
2 Comments

Posted by on January 20, 2011 in AX, Basics, Dynamics, SQL, Tables, X++

 

Tags: , , , , , ,

Creating simple table and data entry form

We will be experiencing the simplest example of creating a simple data entry form. And you will know how easy is to work on AX. I will let you guys know how to create table, what properties need to be set, what methods need to be created, how to define indexes, etc. After creating the table, I will create a simple form with the datasource of the table that we will create. So, lets start by creating a table having data of “Students”. To create a table open the AOT in the development environment of DAX by clicking the AOT button or by short cut key Ctl+D.

Expand the “Data Dictionary” node of the AOT, you will find the “Tables” node. Right click Tables node and click “New table”.


 
 

Now, name the table as “Student”. To add fields to the table, expand the “Student” table, right click and add fields. I am adding these fields.


The properties of fields that must be defined are, “ExtendedDataType” (for FirstName I am defining “Name” as EDT), “Label” & “HelpText” (if different from EDT selected). And The optional properties that’s depends upon requirement are “AllowEdit”, “AllowEditOnCreate”, “Visible” etc. I think the name of the property explains its use, so I am not going into details of defining the use of the property.

 
 

In AX, every table has field RecId which is the Surrogate Key which is being used as a Primary key of the table. If you see the property of the table you will find the Primary Key property and this property is set as “SurrogateKey”. You can define alternate key by creating an Index. To do this, right click the Index node of the “Student” table and add the index. Name the index and set the “AllowDuplicate” property to “No”. Right click this index and add field(s) that you want to make as alternate key. In my case I am adding only the “RegNo” on the index. You can define more indexes as well.

Other properties that need to be set of the tables are “Label”, “TitleField1”, “TitleField2”, “ConfigurationKey”, “TableGroup”. If you want to know the detail of these properties, ask me question, I will answer it.

There is also a “method” node on the table, you can define methods at table level as well. The standard methods that must be there in every tables are “find”, “exists”, “checkExists”. You can find the example of these methods in any of the table present in the DAX. There are also override-able methods of tables, like “validateWrite”, “validateField”, “insert”, “update” and so on. Right click the method node and see override method>.

So, you have created a simple table, now you can use this table as a datasource of a form. To create a form, go to AOT>Forms node and right click to add a new form. Name the new form as “Student”. Expand the form you will find these nodes.


 
 

To add the datasource you can do by dragging the table to the “Data sources “node of the form or by right click and add the table. I am dragging “Student” table on the datasource of the form. Now, the datasource has been added, its time to design the form. Expand the Designs node, and right click the design to add controls, you will have following list of controls.


 
 

In AX 6.0 we have a control “Action pane”, you can use the Action pane as an “Action pane strip” by setting the style property of “Action pane” as “strip”. On that you can add buttons and its looks like the following,


 
 

The controls I am adding in our case are, Action pane strip with command button “New” and “Delete Record”, Two tab pages “Overview” which contains grid and “General” which contains fields.

On the grid you can drag fields from datasource node of the form. Same for other controls, you can drag fields from datasource to any group control or tab page.

After all this you can open the form, and you can add or remove records. The form will look like this.

 
 


 

Thanks guys for reading the post. Any suggestion or question will be highly appreciated.

 
1 Comment

Posted by on April 27, 2010 in AX, Dynamics, Forms, Tables, Uncategorized

 

Tags: , , , ,

Playing with data

In this post, I am going to discuss about how the data can be retrieved, created, updated or deleted using data access and manipulating functionality provided by Dynamics AX framework. In DAX, developer doesn’t need to worry about opening the database connection, make transaction or fetching data, and close the connection. Rather doing these steps DAX framework requires only the table buffer variable to make transaction or manipulating data. What is table buffer? Hmmm, a table buffer is a variable of any Table which stores complete records, for example you can access any field of the table using that variable. Let’s take a simple example. In the Table node of the AOT, we have a table called “CustTable”, now we can declare a table buffer as,

 
 

CustTable custTable; ///table buffer variable of table type “CustTable”

 
 

A table buffer must be declared before using the select statement to retrieve data. The select statement is based on the SQL standard and quite similar to SQL server query statement except the fact that joining is little different for example there is no “ON” keyword in X++. The developer having experience in LINQ won’t have a problem in understanding the working of data access implementation in DAX. See the below simple job and its result.

 
 

static void Select_Statement(Args _args){

CustTable custTable;

select firstOnly custTable;

print custTable.AccountNum + ” ” + custTable.CustGroup;

pause;

}

And the result after running this job is, 
 


 

Now lets analyze the job, firstly a table buffer of table CustTable is declared, and in the 2nd line a select statement is written with the keyword “firstonly” which retrieves only one record based on the primary index defined on the Table. The “firstonly” keyword called the find option in DAX. The other find option keywords are “forUpdate”, “noFetch”, “firstFast”, and “reverse”. You can also define multiple find option keyword within a single select statement. A field list can also be provided with the select statement with the keyword “from”, for example,  
 

select firstoOnly AccountNum, CustGroup from custTable;  
 

Note: its now the BP error if not define the field list in the select statement in the AX 6.0 version.

Can we fetch multiple records? Yes, we can fetch multiple records using the “while” keyword with the select statement. The while loop will continue until all the records is fetched based on the condition in the where clause of the select statement. If now condition is defined, the loop will execute till the last record. 
 

See and observe the output of the following job. 
 

static void Select_Statement(Args _args){CustTable custTable;

while select AccountNum, custGroup from custTable

where custTable.CustGroup == “40”

{

print custTable.AccountNum + ” ” + custTable.CustGroup;

}

pause;

}

 
 

Aggregate functions like sum, count, avg etc. can be used in the select statement like,  
 

select count(AccountNum) from custTablegroup by custTable.CustGroupwhere custTable.CustGroup == “40”;

print custTAble.AccountNum;

 

Lets talk about “joins” in DAX, how we can join multiple tables in the select statement. See the below simple example of join, which joins custTable with custGroup table. 
 

static void Select_Join_Statement(Args _args){CustTable custTable;

CustGroup custGroup; 
 

while select * from custTable

join * from custGroup

where custTable.CustGroup == custGroup.CustGroup

&& custGroup.Name == “Wholesalers”

{

print custTable.AccountNum + ” ” + custTable.Currency + ” ” + custGroup.PaymTermId;

}

pause;

}

Instead of “On” keyword “where” keyword is used to join the same field of the tables that needs to be joined. The Join can be of type “Inner”, “outer”, “exists”, and “not exists”. There is no inner keyword so if the keyword join is written without the other keyword is referred to as inner join. See the below explanation of join types,

Join Type Explanation
join Fetches the records that matches on both the table. It is the inner join.
outer join Fetches the records whether or not records matches on both the table.
exists join Fetches record from the table define before the exists keyword that matches with the records in the 2nd table. No records will be fetched from thesecondary table using exists join.
notexists join Opposite of exists join. Will fetch records from the primary table, where norecords in the secondary table match the join expression.

 

Try and observe the join type result by creating a job. 

Now lets talk about insert, update, and delete records from the table. These will also be done by using the table buffer. In the table buffer, we have methods, of insert, update , and delete. To insert a record into table, declare table buffer, set values of the fields and call insert method of that table buffer. For example, 

static void Insert_Job(Args _args){

CustTable custTable;

custTable.AccountNum = “4444”;

custTable.Currency = “USD”;

custTable.insert();

}

Similarly, to update the record, update method will be called, but first records need to be fetched using the select statement with the keyword “forupdate”. 
 

static void Update_Job(Args _args){

CustTable custTable;

select forupdate * from custTable where custTable.AccountNum == “4444”; 

custTable.Currency = “EUR”;

custTable.update();

}

You can also update the record using the statement “update_recordset

update_recordset custTablesetting currency = “EUR”where custTable.AccountNum ==”4444″;

 

Now to delete the record, you can delete the record in two ways, either fetch the record using the forupdate keyoword and call the delete method of table buffer or using the delete_from statement.

static void Delete_Job(Args _args){

CustTable custTable;

select
forupdate * from custTable where custTable.AccountNum == “4444”;

custTable.delete();

}

Or using delete_from like,

delete_from custTablewhere custTable.AccountNum ==”4444″;

Inserting, updating, and deleting records are placed under the ttsbegin; and ttscommit; block. These keywords are usually placed to make sure that the transactions to database have been done successfully. If any failure occurs during the transaction then the state will be roll back to position before the ttsbegin keyword. ttsabort; keyword is also used when any exception occurs and transaction needs to be aborted.

 Thanks for reading.

 
2 Comments

Posted by on April 16, 2010 in Basics

 

Tags: , , , ,