FK_ModelElementData_HasModelId_LayerId error

After applying the feature pack to an AX 2012 environment, during the full AOT compilation, I got the error as below:

Object Server 01:  The database reported (session 3 (Admin)): [Microsoft][SQL Server Native Client 10.0][SQL Server]The UPDATE statement conflicted with the
FOREIGN KEY constraint “FK_ModelElementData_HasModelId_LayerId”. The conflict occurred in database
“MicrosoftDynamicsAX”, table “dbo.Model”.. The SQL statement was: “{ CALL [dbo].[XU_Update](?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }”

Actually the error is due to the fact that the syp layer of class HcmWorkerImport_DirPartyContactInfoView can’t be saved.

Microsoft released a hotfix to fix this issue, however, you need to redo the upgrade with a restored backup and than install the kernel hotfix and slipstream the hotfix in your AX 2012 Feature Pack installation files. Apparently this is not working for a production environment installation: sometimes we can’t afford to change the Modelstore in production environment.

http://blogs.msdn.com/b/axsupport/archive/2012/07/19/error-when-upgrading-to-ax-2012-feature-pack-the-update-statement-conflicted-with-the-foreign-key-constraint-quot-fk-modelelementdata-hasmodelid-layerid-quot.aspx

After doing some investigation, I manage to manually fix these issues:

1. Use SQL Server Profiler to profile the compiling statement issued by AOS

image

2. Based on the query we got from step 1, find out which AOT element is causing the problem

image

3. Look up the correct element ID and handles in Meta database.

image

image

Now you can see the different Parent AXId of method “ExistLocationName”: ‘1023865’ and ‘1025020’

4. From AOT to open the system view “SysModelElement”.

image

5. The solution to this is to change the wrong parentID from ‘1025020’ to ‘1023865’ :

Run the following query on SQL Server to update the Table MODELELEMENT:

image

Advertisement
Posted in 未分类 | Leave a comment

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in 未分类 | Leave a comment

Use ScriptManager to close the EP page window

Using RegisterStartupScript we can write a JavaScript function in code behind and call it from code-behind. For example,  to close a page window, we can use the following code in .cs file:

protected void Button1_Click(object sender, EventArgs e)
{

    …

     string closeWindowScript= "window.close()";
     ScriptManager.RegisterStartupScript(this, typeof(string), "CLOSE_WINDOW", closeWindowScript, true);

}

Hope it helps.

Posted in 未分类 | Leave a comment

Use CSS style to customize Enterprise Portal 2009 page

Sometimes we are asked to customize the layout of a page. The changes are often small and don’t necessarily require a change to the site master page or css file. For example, the client requests to hide the ‘Site Action’ menu on a Dynamics AX 2009 EP page to disable the user to change the page layout.

Now I use the purchase requisition lists as an example:

image

On the page, right click and select View Source

image

In the source file, the CSS class used in Site Action menu is .ms-siteaction

image

Open Visual Studio 2008 and edit the user control PurchReqTableList. In the PurchReqTableList.ascx file, add the following code

<style type="text/css">
    .ms-siteaction { display:none ;}
</style>

image

Save the change and update the portal.

Now you can see the ‘Site Action’ menu is gone.

image

Similarly, if we want to hide the breadcrumbs, we can use the same way as well.

image

Put the following code in the .ascx file:

<style type="text/css">
    .ms-siteaction { display:none ;}  .ms-sitemapdirectional { display: none; } .ms-titlearea { display: none; }
</style>

Save the changes and update the portal, you will find both the breadcrumbs and site action menu are gone.

image

Posted in 未分类 | 1 Comment

Debugging AX2009 Enterprise Portal and Batch jobs running on Windows 2008

The hotfix KB962952 has been released. You can contact technical support for Microsoft Dynamics and create a new support request to get the hotfix.

Posted in 未分类 | Leave a comment

CDO.Message error

When we use the Dynamics AX to send email, sometimes we will run into an CDO.Message issue with error message Method ‘send’ in COM object of class ‘CDO.Message’ returned error code 0x80040211 (<unknown>) which means: <unknown>.

The error codes listed below are really useful when troubleshooting the issue:

Value Remarks
0x80040201 Exception %1 was generated at address %2.
0x80040202

No data source has been opened for the object.

0x80040203

The object does not support this type of data source.

0x80040204

The object does not support the requested property name or namespace.

0x80040205

The object does not support the requested property.

0x80040206

The object is not active. It may have been deleted or it may not have been opened.

0x80040207

The object does not support storing persistent state information for objects.

0x80040208

The requested property or feature, while supported, is not available at this time or in this context.

0x80040209

No default drop directory has been configured for this server.

0x8004020A

The SMTP server name is required, and was not found in the configuration source.

0x8004020B

The NNTP server name is required, and was not found in the configuration source.

0x8004020C

At least one recipient is required, but none were found.

0x8004020D

At least one of the From or Sender fields is required, and neither was found.

0x8004020E

The server rejected the sender address. The server response was: %1

0x8004020F

The server rejected one or more recipient addresses. The server response was: %1

0x80040210

The message could not be posted to the NNTP server. The transport error code was %2. The server response was %1

0x80040211

The message could not be sent to the SMTP server. The transport error code was %2. The server response was %1

0x80040212

The transport lost its connection to the server.

0x80040213

The transport failed to connect to the server.

0x80040214

The Subject, From, and Newsgroup fields are all required, and one or more was not found.

0x80040215

The server rejected the logon attempt due to authentication failure. The server response was: %1

0x80040216

The content type was not valid in this context. For example, the root of an MHTML message must be an HTML document.

0x80040217

The transport was unable to log on to the server.

0x80040218

The requested resource could not be found. The server response was: %1.

0x80040219

Access to the requested resource is denied. The server response was: %1.

0x8004021A

The HTTP request failed.  The server response was: %1.

0x8004021B

This is a multipart body part. It has no content other than the body parts contained within it.

0x8004021C

Multipart body parts must be encoded as 7bit, 8bit, or binary.

0x8004021E

The requested property was not found.

0x80040220

The "SendUsing" configuration value is invalid.

0x80040221

The "PostUsing" configuration value is invalid.

0x80040222

The pickup directory path is required and was not specified.

0x80040223

One or more messages could not be deleted.

0x80040227

The property is read-only.

0x80040228

The property cannot be deleted.

0x80040229

Data  written to the object are inconsistent or invalid.

x8004022A

The requested property is not in the mail header namespace.

0x8004022B

The requested character set is not installed on the computer.

0x8004022C

The ADO stream has not been opened.

0x8004022D

The content properties are missing.

0x8004022E

Content properties XML must be encoded using UTF-8.

0x8004022F

Failed to parse content properties XML.

0x80040230

Failed to convert a property from XML to a requested type.

0x80040231

No directories were specified for resolution.

0x80040232

Failed to resolve against one or more of the specified directories.

0x80040233

Could not find the Sender’s mailbox.

0x80040234

Binding to self is not allowed.

0x80044000

The first argument is invalid.

0x80044001

The second argument is invalid.

0x80044002

The third argument is invalid.

0x80044003

The fourth argument is invalid.

0x80044004

The fifth argument is invalid.

0x800CCE05

The requested body part was not found in this message.

0x800CCE1D

The content encoding type is invalid.

Posted in 未分类 | 5 Comments

Send workflow notification as email

In AX2009, we can email the workflow notifications. The following steps will show you how to set this up:

1. Create an email template for workflow.

Go to Basic –> Setup –> Email Templates. Create a new email template for workflow notification.

image

2. Set workflow to use the template that is created from step 1.

Go to Basic –> Setup –> Settings for workflow. Select the email template on the General tab.

image

3. Enable “Send notifications as e-mail message” for the user.

Tools –> Options.

image

Posted in 未分类 | 1 Comment

Dynamics AX 2009: Write to eventlog entry

Our client requested to keep track of all Dynamics AX system errors during the User Acceptance Testing. I use the application event logs to store the information.

The following code shows you how to write event log entry with X++:

Create a new class AX_EventLog with a static method WriteEventLog:

static void WriteEventLog(Exception _exception, str _event)
{
    str eventSource = "AX event";
    str logType = "Application";
    System.Diagnostics.EventLogEntryType eventLogEntryType;
    int eventCategory = 9999;
    ;

    switch(_exception)
    {
        case Exception::Info:
            eventLogEntryType = System.Diagnostics.EventLogEntryType::Information;
            break;
        case Exception::Warning:
            eventLogEntryType = System.Diagnostics.EventLogEntryType::Warning;
            break;

        default:
            eventLogEntryType = System.Diagnostics.EventLogEntryType::Error;
    }

    if (!System.Diagnostics.EventLog::Exists(eventSource))
    {
        System.Diagnostics.EventLog::CreateEventSource(eventSource, logType);
    }

    System.Diagnostics.EventLog::WriteEntry(eventSource, _event, eventLogEntryType, eventCategory);
}

In the Info class,

image

Exception add(
    Exception _exception,
    str _txt,
    str _helpUrl = ”,
    SysInfoAction _sysInfoAction = null,
    boolean buildprefix = true)
{
    …
    AX_EventLog::WriteEventLog(_exception, _txt);
    …

}

Here we go, event log entry…

image

Posted in Axapta Development | Leave a comment

Argument passed to ‘KPIVALUE’ function must be a KPI name

During the past two weeks, I have been troubleshooting the Reporting Services Error on the AX2009 Enterprise Portal, especially for the ‘argument passed to the ‘KPIVALUE’ function must be a Key Performance Indicator (KPI) name’ issue.

image

In the following steps, I will show you how to troubleshoot the error with the not-functioning ‘KPI for Project Manager’ Report server report.

  • Find out the report library on the AOT.

On the SharePoint portal, click ‘Site Actions’ –> Edit pages, look for the report name.

image

Open an AX client, go to Tools –> Development tools –> Label –> Label Editor and enter ‘KPI for Project Manager’, which we will get the label ID ‘@SYS121988’.

image

In AX client, open an AOT tree, go to Menu items –> Output node, and right click and choose Find.

In the search dialog, choose All nodes and in ‘Containing text’, enter the label ‘SYS121988’.

image

Now we get the object which is ‘ProjKPI_ProjectManager’. In the AOT, go to Menu Items –> Output node and locate the ‘ProjKPI_ProjectManager’ and right click and choose properties.

image

On the properties, we get the object which is ‘ProjKPI.ProjKPI.KPI’.

  • Edit the report library in Visual Studio 2008

Go to AOT –> Report libraries, and locate ‘ProjKPI’ and right click and choose ‘Edit in Visual Studio’ which will open Visual Studio 2008.

Because in the error ‘Query execution failed for dataset ‘NetWIP’. We double click the ‘NewWIP’ dataset in Visual Studio 2008.

image

Press F5 to execute the query, put in company account value and click OK.

image

The same error as on the portal.

image

  • Debug in SQL Server Business Intelligence Development Studio

Start the SQL Server Business Intelligence Development Studio from Start –> Programs –> SQL Server 2005 –> SQL Server Business Intelligence Development Studio.

Click File –> New –> Project, and select project type ‘Import Analysis Service 9.0 Database’.

image

Click OK, then a wizard will guide you through to import the database.

image

image

image

Based on the query to build the ‘NEWWIP’ dataset:

“… 

SELECT {[MEASURES].[INDICATOR],KPIValue("Actual vs Budget Net WIP"), KPIGoal("Actual vs Budget Net WIP"),
KPIStatus("Actual vs Budget Net WIP"), KPITrend("Actual vs Budget Net WIP")} ON COLUMNS

FROM [Project Accounting Cube]

…”

The dataset is built upon [Project Accounting Cube].

Select ‘[Project Accounting Cube] in the solution explorer. and choose ‘View designer’.

image

Change to ‘KPI’ tab,and choose the ‘Actual vs Budget Revenue’

image

From the Value Expression, we can see the KPI is defined on the basis of measure ‘Budget Revenue’ and measure  ‘Actual Revenue’.

(([Measures].[Budget Revenue]-[Measures].[Actual Revenue])/[Measures].[Budget Revenue])*100

Expand the Measures in the ‘Metadata’ tab of the ‘Calculation Tools’ section.

image

OOPS!!!!!! Can’t find the ‘Budget Revenue’ measure!!!!!!!

image 

Okay, now we see, must be something wrong with the ‘Budget Revenue’ measure. Change to ‘Calculation’ tab in the same ‘Project Accounting Cube’.

Choose the ‘Budget Revenue’ Calculated Member.

image  

It is derived from another two Calculated Members – ‘Budget invoiced revenue’ and ‘Budget accrued revenue’.

Expression for ‘Budget invoiced revenue’:

image

Expression for ‘Budget accrued revenue’:

image

Both of them are based on the Dimension ‘Budget updates’, and they do not appear under the Measures as well, which means the data are not populated properly.

image

Expand the ‘Budget updates’ in the Metadata tab.

image

Here we go, we found the cause of the issue. No transactions in the Budget Update dimension.

Go to the Solution explorer, and edit the ‘Budget updates’ dimension.

image 

image

From the property, we can see the ENUM ProjTransType is from the following query:

SELECT A.ENUMITEMVALUE, A.ENUMITEMLABEL AS ENUMITEMNAME FROM [DBO].SRSANALYSISENUMS A WHERE A.ENUMID = 383 AND A.LANGUAGEID = ‘en-us’

Let us check this table from the SQL Server Management Studio. All good, the records are there. (We need to check the ProjPaymentStatus, LedgerPostingType as well.)

image

Then must be the issue that the dimension is not processed properly.

From the expression for ‘Budget invoiced revenue’ :

Sum
(
    (
        {[Budget updates].[Transaction type].&[1], [Budget updates].[Transaction type].&[2],
        [Budget updates].[Transaction type].&[3], [Budget updates].[Transaction type].&[4]},
        [Budget updates].[Posting type].&[126]
    ),
    [Measures].[Budget updates Amount] *-1
)
+
Sum
(
    (
        {[Budget updates].[Transaction type].&[5]},
        [Budget updates].[Posting type].&[127]
    ),
    [Measures].[Budget updates Amount] *-1
)

Make sure in the ProjTransBudget table (Dimension [Budget updates]) contain the records meeting the above criteria.

Process the ‘Budget updates’ dimension now.

image

image 

Click ‘Yes’ button.

image

image

Click Run to process the ‘Budget updates’ dimension.

image

Reconnect again

image

Reload the role center…

image

Posted in SSAS & BI | Leave a comment

Dynalink in Dynamics AX 2009 Enterprise Portal

The classic Dynalink is still available when we are programming AX2009 Enterprise Portal.

So normally during the Enterprise portal programming, we don’t need to pass the parameter by using CreatingDataSetRun event to create the QueryBuildRange object and specify the range value (AX did that for us already!), if we have the table or EDT relations set up properly.

Apparently the context record is passed by the QueryString parameters.

For example, the QueryString “EPProjTableInfo.aspx?WTID=624&WKEY=%5b65534%3a5637144829%5d&WCMP=DAT”, AX will retrieve the context record by using the unique pair value (WTID = TableId, WKEY = RecId).

In the user control, we can use the following code to get the context record:

using Microsoft.Dynamics.Framework.Portal.UI;

using Microsoft.Dynamics.Framework.Metadata.Ax;

using Microsoft.Dynamics.Framework.Data.Ax;

    …

 

    AxTableContext context = AxBaseWebPart.GetWebpart(this).ExternalContext;

    if (context != null &&

        context.TableId == TableMetadata.TableNum(AxBaseWebPart.GetWebpart(this).Session, “ProjTable”))

    {

        string projId = context.DateKey.GetRecord(this.AxSession).GetField(“ProjId”).ToString()’;

    }

 

In the DataSet, we can use args objects to return the context record as we do in AX client programming:

public void init()

{

    TableId tableId;

    ProjTable projTable;

    ProjId projId;

    super();

    tableId = element.args().dataSet();

    switch(tableId)

    {

        case tableNum(ProjTable):

                projTable = element.args().record();

                projId = projTable.projId;

                break;

         …

    }

    …

}

Posted in Enterprise Portal | Leave a comment