Philippsen's Blog

Everyday findings in my world of .net and related stuff

Posts Tagged ‘EP’

Unable to render content due to an error. Please contact your system administrator.

Posted by Torben M. Philippsen on May 23, 2016

Recently I experienced a strange error in an usercontrol. The error would cause the classic “Unable to render content due to an error. Please contact your system administrator.” message on EP and in the eventviewer I saw this:

EV1

EV2

EV3

The strange thjing turned out to be that the code for the usercontrol was an exact match with the one from a reference environment where everything worked just fine.

Trying to narrow things down I ended up finding that it was the AllowPaging property on the grid that was set to false that caused the error. Setting this property to true, would make the control work just fine. However my customer didn’t want paging – and it woked just fine in the reference environment. Giving this thought I concluded that the error was related to data. In my environment the dataset would return 55 records and in the reference environment I would have just 12 records. I started to play around with the PageSize property of the grid and found the the magic limit was 45 records. A limit of 44 in the PageSize property would make the control work just fine, whereas a limit of 45 would make the control crash with the above eventlog entries to follow.

I don’t think that the error is related to 45 records but more likely the size of the entire dataset. In my case the dataset contains information about expences and in that context some image/binary bitmap data. I therefore expect the data to be quite big.

 

Conclusion:

If you begin to experience strange errors like the ones above – maybe it would be a good idea to look into the size of data.

Advertisements

Posted in Enterprise Portal Development, Microsoft Dynamics AX | Tagged: , | Comments Off on Unable to render content due to an error. Please contact your system administrator.

Troubleshooting Enterprise Portal error messages

Posted by Torben M. Philippsen on April 4, 2016

If you have been working with enterprise portal development, you will probably have gone through the same levels of frustration as I because error messages are not good in adding usable information into these messages. Over time I have collected some sites with suggestions on how to troubleshoot these more or less cryptric messages.

Error: Enterprise Portal Web Parts show "Unable to render content" error
https://blogs.msdn.microsoft.com/emeadaxsupport/2010/09/23/enterprise-portal-web-parts-show-unable-to-render-content-error/

Error: Unable to render content due to an error. Please contact your system administrator.
https://blogs.msdn.microsoft.com/emeadaxsupport/2010/11/17/how-to-troubleshoot-enterprise-portal-error-unable-to-render-content-due-to-an-error-please-contact-your-system-administrator/

Generel troubleshooting: https://msdn.microsoft.com/en-us/library/cc554278.aspx

Posted in Enterprise Portal Development, Microsoft Dynamics AX | Tagged: , , , , | Comments Off on Troubleshooting Enterprise Portal error messages

Display image from AX as embedded object in usercontrol

Posted by Torben M. Philippsen on January 9, 2015

Example of usercontrol markup:

<%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”DIVendInvoiceImage.ascx.cs” Inherits=”DIVendInvoiceImage” %>

<%@ Register Assembly=”Microsoft.Dynamics.Framework.Portal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

    Namespace=”Microsoft.Dynamics.Framework.Portal.UI.WebControls.WebParts” TagPrefix=”dynamics” %>

<%@ Register Assembly=”Microsoft.Dynamics.Framework.Portal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

    Namespace=”Microsoft.Dynamics.Framework.Portal.UI.WebControls” TagPrefix=”dynamics” %>

<%@ Register Assembly=”Microsoft.Dynamics.Framework.Data.Ax, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

    Namespace=”Microsoft.Dynamics.Framework.Data.Ax” TagPrefix=”dynamics” %>

<%@ Register Assembly=”Microsoft.Dynamics.Framework.Metadata.Ax, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

    Namespace=”Microsoft.Dynamics.Framework.Metadata.Ax” TagPrefix=”dynamics” %>

<%@ Register Assembly=”Microsoft.Dynamics.Framework.BusinessConnector, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

    Namespace=”Microsoft.Dynamics.Framework.BusinessConnector” TagPrefix=”dynamics” %>

<%@ Register Assembly=”Microsoft.Dynamics.Framework.BusinessConnector.Proxy, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

    Namespace=”Microsoft.Dynamics.Framework.BusinessConnector.Proxy” TagPrefix=”dynamics” %>   

<%@ Register Assembly=”Microsoft.Dynamics.Framework.Portal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

    Namespace=”Microsoft.Dynamics.Framework.Portal.UI.WebControls.Workflow” TagPrefix=”dynamics” %>    

 

 <dynamics:AxDataSource ID=”DS_VendInvoiceImage” runat=”server”

    DataSetName=”DIVendInvoiceImage” ProviderView=”LedgerJournalTrans” />

 

<dynamics:AxMultiSection

    ID=”AxMultiSection1″ runat=”server”>

<dynamics:AxSection ID=”AxSection_Image” runat=”server” Caption=”Faktura”

        Expanded=”True” >

    <%=showImage() %> 

</dynamics:AxSection>

</dynamics:AxMultiSection>

Usercontrol codebehind

using System;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Globalization;

using Microsoft.Dynamics.Framework.Portal;

using Microsoft.Dynamics.Framework.Portal.UI.WebControls;

using Microsoft.Dynamics.Framework.Portal.UI.WebControls.WebParts;

using Microsoft.Dynamics.Framework.Portal.UI.WebControls.Workflow;

using Microsoft.Dynamics.Framework.Portal.UI;

using Microsoft.Dynamics.Framework.Data.Ax;

using Microsoft.Dynamics.Framework.Metadata.Ax;

using Microsoft.Dynamics.Framework.BusinessConnector;

using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;

using ApplicationProxy = Microsoft.Dynamics.Portal.Application.Proxy;

using Microsoft.Dynamics.Framework.BusinessConnector.Session;

using Microsoft.Dynamics.Framework.BusinessConnector.Adapter;

using System.Collections.Generic;

using System.Diagnostics;

 

public partial class DIVendInvoiceImage : System.Web.UI.UserControl

{

    string imageHtml;

 

    protected string showImage()

    {

        return imageHtml;    

    }

    protected void Page_Load(object sender, EventArgs e)

    {

        AxBaseWebPart.GetWebpart(this).ExternalContextChanged += new EventHandler<AxExternalContextChangedEventArgs>(ExternalContextChanged);

       

    }

 

    void ExternalContextChanged(object sender, AxExternalContextChangedEventArgs e)

    {

        IAxaptaRecordAdapter currentRecord = AxBaseWebPart.GetWebpart(this).ExternalRecord;

        if (currentRecord != null)

        {

            imageHtml = (string)this.DS_VendInvoiceImage.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call(“showImage”, (Int64)currentRecord.GetField(“RecId”), Convert.ToString(AxBaseWebPart.GetWebpart(this).Width), Convert.ToString(AxBaseWebPart.GetWebpart(this).Height));

 

        }

    }

 

}

 

ShowImage method on dataset (x++ code) – pushing differenet kinds of object tags

//Called from ASP.NET

str showImage(RecId _ledgerJournalTransRecId, str _widthZone = ‘450px’, str _heightZone = ‘600px’)
{
#Web
NAX_ScanImageTable      NAX_ScanImageTable;
str                     ret;
str                     url;
LedgerJournalTrans      ledgerJournalTransLocal = LedgerJournalTrans::findRecId(_ledgerJournalTransRecId, false);
EPWebsiteParameters     EPWebsiteParameters;
;

    _widthZone = ‘470px’; // tec, cts, 2011.01.20, Defect 229,335  width changed from 250px to 350px
_heightZone = ‘450px’;

    ret = ‘<P style=”TEXT-ALIGN: center”>’+’@VIA98’+'</p>’;
NAX_ScanImageTable = NAX_ScanImageTable::find(ledgerJournalTransLocal.naxImageId);
if (NAX_ScanImageTable.ScanImage)
{
select firstOnly EPWebsiteParameters;
url = EPWebsiteParameters.ExternalUrl+’/’+#resourcesRelDir+’/diimageaction.aspx?’;
url +=’table=’+int2str(NAX_ScanImageTable.tableId);
url +=’&field=’+int2str(fieldnum(NAX_ScanImageTable,ScanImage));
url +=’&recid=’+int642str(NAX_ScanImageTable.RecId);
//EG/2015.01.07/EGTOP, 00414358 Integration til Picasso –>
url += ‘&fileType=’+NAX_ScanImageTable.ImageFormat;
//EG/2015.01.07/EGTOP, 00414358 Integration til Picasso <–
//EG/2015.01.07/EGTOP, 00414358 Integration til Picasso –>
//do something to handle pdf file extension
if (NAX_ScanImageTable.ImageFormat == ‘pdf’)
{
ret = strfmt(‘http://%2‘, url, url);
}
else
{
//if not pdf do as usual – handle as tiff
//EG/2015.01.07/EGTOP, 00414358 Integration til Picasso <–
ret = strfmt(‘http://%2‘, url, url);

          //EG/2015.01.07/EGTOP, 00414358 Integration til Picasso –>
}
//EG/2015.01.07/EGTOP, 00414358 Integration til Picasso <–
}
else if(NAX_ScanImageTable.Text)
{
ret = ‘<DIV id=”bsplustxt”>’+NAX_ScanImageTable.Text+'</DIV>’;
}
return ret;
}

diimageCaption.aspx markup and code – setting the content type according to the memorystream content:

<%@ Page Language=”C#” Trace=”false” %>

<%@ Assembly Name=”Microsoft.Dynamics.BusinessConnectorNet, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null” %>

<%@ Assembly Name=”Microsoft.Dynamics.Framework.Portal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null” %>

<%@ Assembly Name=”Microsoft.Dynamics.Framework.BusinessConnector, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null” %>

<%@ Assembly Name=”Microsoft.Dynamics.Framework.BusinessConnector.Proxy, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null” %>

<%@ Import Namespace=”Microsoft.Dynamics.BusinessConnectorNet” %>

<%@ Import Namespace=”Microsoft.Dynamics.Framework.Portal” %>

<%@ Import Namespace=”Microsoft.Dynamics.Framework.BusinessConnector.Proxy” %>

<%@ Import Namespace=”Microsoft.Dynamics.Framework.BusinessConnector.Session” %>

<%@ Import Namespace=”Microsoft.Dynamics.Framework.BusinessConnector.Adapter” %>

 

<script runat=”server”>

    void Page_Load(object sender, EventArgs e)

    {

        string table = this.Request.QueryString[“table”];

        string field = this.Request.QueryString[“field”];

        string recid = this.Request.QueryString[“recid”];

        //EG/2015.01.07/EGTOP, 00414358 Integration til Picasso –>

        string fileType = this.Request.QueryString[“fileType”];

        //EG/2015.01.07/EGTOP, 00414358 Integration til Picasso <–       

        if (recid != null && recid != String.Empty)

        {

            AxSharepointWebSession session = null;

            try

            {

                table = table == null ? String.Empty : table;

                field = field == null ? String.Empty : field;

 

                session = SessionHelper.Instance.GetSharepointSession();

 

                if (session != null)

                {

                    session.InitWeb(HttpContext.Current, Page.IsPostBack);

                    string base64 = (string)session.AxaptaAdapter.CallStaticClassMethod(“Webapplication”, “GetImage”,

                                    int.Parse(table), int.Parse(field), long.Parse(recid));

                    

                    byte[] bytes = Convert.FromBase64String(base64);                   

                    if (bytes != null && bytes.GetLength(0)>0)

                    {

                        //EG/2015.01.07/EGTOP, 00414358 Integration til Picasso –>

                        string contentType;

                        if (fileType.Equals(“pdf”))

                        {

                            contentType = “application/pdf”;

                        }

                        else

                        {

                            //EG/2015.01.07/EGTOP, 00414358 Integration til Picasso <–

                            contentType = “image/tiff”;

                            //EG/2015.01.07/EGTOP, 00414358 Integration til Picasso –>                           

                        }

                        //EG/2015.01.07/EGTOP, 00414358 Integration til Picasso <–

                        this.Response.ContentType = contentType;

                        this.Response.BinaryWrite(bytes);

                    }

                }

            }

            catch (System.Exception E)

            {

                System.Diagnostics.EventLog.WriteEntry(“EP”, string.Format(“Error {0}”, E.Message),System.Diagnostics.EventLogEntryType.Error, 3);

           

            }

            finally

            {

                if (session != null)

                {

                      SessionHelper.Instance.ReleaseSharepointSession(session);

                }

            }

        }

    }   

</script>

Posted in Enterprise Portal Development | Tagged: , , , | Comments Off on Display image from AX as embedded object in usercontrol

 
%d bloggers like this: