Thursday, April 3, 2014

Table 'TableName' used in report provider class should be a regular table.

This is because the RDP class extends the SRSReportDataProviderPreprocess class. to resolve this, you can do following steps:

1. Replace SRSReportDataProviderPreprocess with SRSReportDataProviderBase, but you will not be able to debug the report if it extends from SRSReportDataProviderBase.

2. Change properties of the report's tmp table CreatedBy and CreatetransactionId to 'yes', Also make the table as regular table.

Friday, November 1, 2013

How to use entry point security in x++ based on a record

I had one requirement where in Sales order form the records which are confirmed must not be allowed to edit for a user role. This can be resolved by two ways:


1. To check the current user role and making the edit button as false on a condition,override active method of datasource and code as below:

select role
        where role.Name == 'RoleName'
    join userRole
        where userRole.SecurityRole == role.RecId
            && userRole.User == curUserId();
    if(userRole && SalesTable.DocumentStatus == DocumentStatus::Confirmation)
    {
    editButtonAllow= false;
    }

2. To avoid hard coding the Roles, we can use an entry point and check users access to the entry point

we need to create a menu item with a privilege and duty assigned to a role, override active method of datasource and use the menu item as below:

SecurityRights      sr;
AccessRight         accessRight = AccessRight::View;
sr = SecurityRights::construct();

accessRight = sr.menuItemAccessRight(SecurableType::MenuItemAction,menuitemActionstr(MenuItemName));
if(accessRight == AccessRight::View && SalesTable.DocumentStatus == DocumentStatus::Confirmation)
{
    ButtonName.enabled(false);
}
 else
 {
    ButtonName.enabled(true);
  }

Thursday, August 22, 2013

Modify XML using XSL outbound transform AX 2012



Once I got a client requirement to make changes into the outbound XML generation of electronic VendPayment. Since their bank was not able to accept the current format of the XML generated from AX.
The XML includes Envelope and Header tags with output XML which sometimes needs to be truncated so that the third party applications can read the output XML.
To resolve this I started fresh by configuring the VendPayment using AIF outbound port setup using following Link.
The only change in the above configuration I did is I included the XSL file generated from the resources to outbound pipeline, no changes here,
I created a second XSL and added it into the outbound transformation(see below)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:wt="schemas.microsoft.com/.../Message" xmlns:xsl="www.w3.org/.../Transform">
            <xsl:output version="1.0" omit-xml-declaration="no" indent="yes" encoding="UTF-8" method="xml"/>
           
<!--Copy all nodes from source-->
-<xsl:template match="@*|node()">-<xsl:copy>
                                    <xsl:apply-templates select="@* | node()"/>
                        </xsl:copy>
            </xsl:template>
           
            <!--Remove header, message parts, body and envelope tags-->
            <xsl:template match="wt:Envelope/wt:Header"/>-<xsl:template match="wt:Envelope/wt:Body/wt:MessageParts">
                        <xsl:apply-templates/>
            </xsl:template>-<xsl:template match="wt:Envelope/wt:Body">
                        <xsl:apply-templates/>
            </xsl:template>-<xsl:template match="wt:Envelope">
                        <xsl:apply-templates/>
            </xsl:template>
</xsl:stylesheet>

This gave me XML document without Envelope, Message part, Body and Header

Reference: http://community.dynamics.com/ax/f/33/t/102465.aspx#.Uhb2Uz_66qk


Thursday, July 18, 2013

Add new fields to existing service table


when adding a new field for exiting service, we need to perform following steps to make the new field available in Visual Studio
1. Update service

- in dev window, go to Tools, AIF, update Document service
- give the service name and put the service operation as required
- select Regenerate data object and AxBC classes

2. Register service check

- Right click service, go to Addins,Register service
- select service, click on service operation button,
- in service operation window click parameter schema
- in parameter schema window, click view schema and check if your new field is mentioned or not

3. Inbound port deactivate/activate

- go to system administration, setup, Services and Application Integration Framework, Inbound/Outbound port
- select the port name and click on deactivate button
- click on service operation button on the right
- check your service is listed or not
- activate the port

4.Refresh service reference in Visual studios

- go to solution explorer
- right click on service reference and select Update service reference
- Build the project