Monday, December 20, 2010

Update AIF service with new field on a table

If you added a field to a base table that utilizes the AIF (aka new field on SalesTable), there are a few steps that are needed to successfully do this. This blog entry assumes that the webservice is already deployed and setup. We will use the Sales Order web service that comes out of the box.

NOTE: Make sure this procedure is done in the proper layer! AKA don't do it in the USR layer.

Step 1: Update the document service (Figure 1 below).


Figure 1 - Dynamics AX -> Tools -> Development Tools -> Application Object Framework -> 'Update Document Service'

Step 2: Select the service class name that will need to be updated (Figure 2 below). The class name will end with '…Service'. Any other class will give an error saying that the class is not a valid service class. Check the two supporting classes options in this feature.

Figure 2 – Updating the Sales Order webservice

Step 3: There may be a number of errors in one of the web services classes (mine was the sales table header class). There seemed to be a problem generating the macros used in the code. I just added them to the class dec of that class and moved on.

Step 4: Regenerate the webservice


Figure 3 – Regenerate the Sales Order webservice

Step 5: Enable the Action Data Policy fields for the endpoints that are currently using this webservice. Since the data policies are governed on an Endpoint by Endpoint level, this is where these new fields will need to be turned off/on. This can be accessed by going to

-Basic -> Setup -> Application Integration Framework

-Select appropriate endpoint id

-Click 'Action policies' button

-Select appropriate Action policy

-Click 'Data policies' button.

-Enable new fields

Once these steps are complete, the web service's schema will allow for additional fields to be changed to allow these new fields to be integrated into the application.

NOTE: The underlying class may need to be deleted in order for things like string size to properly update in the Schema.

Enjoy!

Monday, October 4, 2010

Change the text for when you hover over an AX field - ToolTip

Sometimes there is a need to change the text that is display when a user hovers over a field in an AX form. By default (OOTB), the information that displays is defaulted from the table relations. This is decided in the kernel. If you change the information in the title fields for that table, you will see the automatically generated tooltip information change.

The automatic information will follow the format '[Field Name]: [main tables's first title field], [main table's second title field]'. For example, hover over the item number for a sales order's sales lines. The tool tip should read 'Item number: [InventTable.ItemId], [InventTable.InventName]'. Mine reads 'Item number: 10001, Yellow Basket' but yours will be different. Hovering over the line's unit of measure (salesLine.SalesUnit) will yield 'Unit: [Unit.UnitId], [Unit.Txt]'. Mine reads 'Unit: Each, Each'.

Assuming you don't want to see this. There is an override on the form's field (actually at the field level) called 'toolTip'. Definition: Tooltip (also known as intotip) – a common graphical user interface element which is used in conjunction with a cursor, usually a mouse pointer. http://en.wikipedia.org/wiki/Tooltip

This method's super() returns a string that is formed by grabbing the table relation title fields discussed earlier. All that is needed is to replace the string that is returned from the super and there you have it! Using the strFmt('%1, %2...'), variable1, variable2, ...));, function, you can put any number of variables in here to display. I have not seen a limit... But too much would look dumb so I'd try to keep it to no more than 4.

Wednesday, July 28, 2010

Field in AX table is visible in AOT but not in Table browser or SQL

Question: What's going on if there is a field in an AX table that can be seen in the AOT under the table and in the intellisense, but not in the table browser or SQL tables?

Answer: This is probably due to licensing. The system you are on may not have the appropriate license to use those fields.

The following is an example for you to follow along with and confirm if needed. Lets use the 'standardPalletQuantity' field on the table InventTable:

  • Navigate out to the table in the AOT. Find the field (e.g. standardPalletQuantity), and look at the properties for the ExtendedDataType/Base Enum.
  • We will then navigate to the appropriate node for that EDT/Enum (e.g. WMSStandardPalletQuantity).
  • Look to see if it has a value in the ConfigurationKey property. If it has one (e.g. WMSPallet), we will want to navigate out to that configuration key in the AOT (AOT\Data Dictionary\Configuration Keys).
  • Look to see if the key has a value in the ParentKey property. If it does, we will want to navigate to that configuration key (e.g. WMSAdvanced). This key will be the one we want to look at if it has no value in the ParentKey property. If needed, keep going until you find the top most parent key.
  • The label for the parent configuration key (ParentKey) is 'Warehouse Management II'.
  • Go to Administration -> Setup -> System -> 'License information' -> 'Modules' tab.
  • Once there, look for the label from the parent key in the 'Code description' field. If there is not a set of '*****' in the 'License code' field or the 'Status' is not 'Ok', that is the answer.

If all the license keys looked ok, I would do the exercise above one more time to make sure I didn't get off track. If still unsuccessful, open a ticket with Microsoft. You may need to re-import your license keys as something may have gone wrong in the original import.

Thursday, April 8, 2010

Clear GroupBy on a query for a form

While working on a form, I recently needed to group by Customer account but then use the actual, non-grouped query in a different location. To remove a group by field on a query, find the form's datasource that has the group by and use the following line of code replacing 'FormDataSource' with the target datasource.

FormDataSource_ds.query().ClearGroupBy;

Tuesday, February 9, 2010

Find the length of an Extended Data Type in X++


Need to find the string length of a property in the AOT (e.g. AccountNum is a string size of 20). Below is some code that will do this for you. It will also allow you draw out some other properties of the EDT if you need to.

static void Job1(Args _args)
{
     str edtName = 'NAME_OF_EDT_OBJECT'
     Dictionary dictionary = new Dictionary();
     DictType dictType = dictionary.typeObject(dictionary.typeName2Id(edtName));
     ;

     info (strFmt('Size of %1: %2', edtName, dictType.stringLen()));
}