Friday, 17 January 2014

Development Tips on Application Integration Framework

I have read one article before start development of  AIF. Check the following links

http://axblog4u.wordpress.com/2010/11/23/development-tips-on-application-integration-framework/

http://blogs.msdn.com/b/aif/archive/2012/05/07/how-to-serialize-int-real-properties-with-0-0-00-values-via-aif-outbound-integration.aspx

http://www.dynamics101.com/2013/11/creating-custom-inbound-aif-service-microsoft-dynamics-ax-2012/

Thursday, 16 January 2014

Inbound port of AIF Ax2012 using File system Adapter

Few things must be noted: ( Inbound port of AIF Ax2012 using File system Adapter )
If your client/Other vendor  has given you XML . They want to import in to AX using AIF. Don’t try to import that xml  according to standard schema of that service.
You must change customize schema from Data Policies inbound port according to you xml tags.
After change of Data Policies you must change your XML tags according to sequence of Data Policies enabled fields.
Generate XML according to standard  XML schema  of  AX
You can check schema nodes related to your action from AX  then mention all nodes in your XML.
Do you want to find all active and deactivate service in Ax ?Fallow the following path





Error 1:
Solution:
Such type of error arise when you xml file come's from BizTalk server and your xml tag contain
instead of
so change it into
OR
When you have found above type error then you can go to the following path

Check the xml output fault message in above path and here you can find some fields tags are missing according to standard schema
The tag '/LedgerGeneralJournal/SenderId' is not allowed; it must be removed or marked null.


Error 2:  Invalid document schema. The following error was returned:  Could not find schema information for the element.
Solution: you can verify your XML tags according to your XML schema from Data Policies.

Error 3:  The tag '/LedgerGeneralJournal/DocPurpose' is not allowed; it must be removed or marked null.
Solution: you can verify your XML tags according to your XML schema from Data Policies. Or just pass null for that tag in your XML.
Error 4:  An error has occurred in the services framework. Method: AifMessageInspector::AfterReceiveRequest. Error: System.ServiceModel.FaultException`1[Microsoft.Dynamics.Ax.Services.AifFault]: Request Failed. See the Exception Log for details. (Fault Detail is equal to Microsoft.Dynamics.Ax.Services.AifFault.


Solution: Check the following screen and configure your service according to these number 1 and check your accurate issue in number 2 path
Error 5: 
Stack trace: The company  does not exist.

Solution:
I am using standard Schema of XMl when I am facing above issue. So I have modified my XML schema from data policies and enable that filed in my schema, add new tag of company filed in my XML.
Error 7:   This is an invalid xsi:type 'AxdEntity_CustInvoiceLine'
Solution: Check your service XML Schema and change tag according to Schema.
Error 8:   Account and offset account cannot be the same
Solution:
If XML contain same value in tags of account and offset account then you can face above issue.
Be make sure both  account number and offset account value is change(i.e Account number = 0101 and offset account = 0102).
Error 9: The request failed with the following error:  Invalid document schema. The following error was returned:  Could not find schema information for the element.
Solution:
When you are putt wrong tags according to schema. Check Data Policies on inbound port form and verify your XML tags according to schema.
Error 10: The request failed with the following error:  Object reference not set to an instance of an object
Solution: When you are putt wrong tags according to schema. Check Data Policies on inbound port form and verify your XML tags according to schema.
Or
If your any tag of xml has wrong data according to destination system table data filed data . then verify you are xml data and your destination system data  

also check this link
http://mybhat.blogspot.com/2013/03/aif-object-reference-not-set-to.html

Error 11: The following error was returned:  The required attribute 'class' is missing
Solution:
Verify your XML file according to your XML Schema.
Error 12: The request failed with the following error:  Duplicate message. Message has already been processed.
Solution:
If your xml file contain same message id which one you have already import in Ax.Only change the message id value at the end of id i.e
{5603D03A-4380-404D-9F27-738BE0FEA14F} already inserted message
Change it as following
{5603D03A-4380-404D-9F27-738BE0FEA18F}
Error 13: Error found when validating record
Solution:
Such type of error occurred. When you’re XML tags contain different value than Ax setup value
For example Ax setup value is following
1102
Your XML contain following value
1111

Error 14: The request failed with the following error:  Creation has been canceled.
Solution:  Such type of error occur when your xml mandatory tag is missing in your xml file


Monday, 24 December 2012

Retrieve Signature image of workflow approval user using SQL query in SSRS Report AX




SELECT     TOP (1) COMPANYIMAGE.REFRECID, COMPANYIMAGE.IMAGE, COMPANYIMAGE.REFRECID AS Expr1, EMPLTABLE.EMPLID, SYSCOMPANYUSERINFO.USERID,
                      DIRPARTYTABLE.NAME, EMPLTABLE.TITLE
FROM         COMPANYIMAGE INNER JOIN
                      EMPLTABLE ON COMPANYIMAGE.REFRECID = EMPLTABLE.RECID INNER JOIN
                      SYSCOMPANYUSERINFO ON EMPLTABLE.EMPLID = SYSCOMPANYUSERINFO.EMPLID INNER JOIN
                      WORKFLOWTRACKINGTABLE ON SYSCOMPANYUSERINFO.USERID = WORKFLOWTRACKINGTABLE.USER_ INNER JOIN
                      DIRPARTYTABLE ON EMPLTABLE.PARTYID = DIRPARTYTABLE.PARTYID INNER JOIN
                      PURCHTABLE ON WORKFLOWTRACKINGTABLE.CONTEXTRECID = PURCHTABLE.RECID
WHERE     (COMPANYIMAGE.DATAAREAID = ‘Ceu’) AND (PURCHTABLE.PURCHID = ‘12345’) AND (WORKFLOWTRACKINGTABLE.CONTEXTTABLEID = 345) AND
                      (WORKFLOWTRACKINGTABLE.TRACKINGCONTEXT = 5) AND (WORKFLOWTRACKINGTABLE.TRACKINGTYPE = 4)
ORDER BY WORKFLOWTRACKINGTABLE.DUEDATETIME DESC

Assigned to me filtration of workflow on Purchase Oder Form




public void executeQuery()
{


 QueryBuildRange         rangeCompanyId;
    QueryBuildRange         rangeUserId;
    QueryBuildRange         rangeId;
    QueryBuildRange         rangeStatus;
 Query query;
 QueryBuildDatasource    datasource;
 WorkflowWorkItemTable   workflowWorkItemTable;
 QueryBuildDataSource    qbdsWorkFlowItemTable;
;


 if(Filter.valueStr() == "Assigned To Me" )
                    {

query = new Query();
                 
                    datasource = query.addDataSource(tableNum(PurchTable));

                    // Add child datasource "WorkflowWorkItemTable" to previously created DS
                    qbdsWorkFlowItemTable = datasource.addDataSource(tableNum(WorkflowWorkItemTable));

                    // Set the join mode
                    qbdsWorkFlowItemTable.joinMode(JoinMode::ExistsJoin);

                 
                    qbdsWorkFlowItemTable.relations(true);

                 
                    qbdsWorkFlowItemTable.addLink(fieldNum(PurchTable, RecId),
                    fieldNum(WorkflowWorkItemTable, RefRecId));

                    qbdsWorkFlowItemTable.addLink(fieldNum(PurchTable, TableId),
                    fieldNum(WorkflowWorkItemTable, RefTableId));
                    rangeStatus = qbdsWorkFlowItemTable.addRange(fieldnum(WorkflowWorkItemTable, Status));
                    rangeStatus.value(queryValue(WorkflowWorkItemStatus::Pending));
                    rangeStatus.status(RangeStatus::Locked);
                    rangeCompanyId = qbdsWorkFlowItemTable.addRange(fieldnum(WorkflowWorkItemTable, CompanyId));
                    rangeCompanyId.value(queryValue(curext()));
                    rangeCompanyId.status(RangeStatus::Locked);

                    rangeUserId = qbdsWorkFlowItemTable.addRange(fieldnum(WorkflowWorkItemTable, UserId));
                    rangeUserId.value(queryValue(curuserid()));
                    rangeUserId.status(RangeStatus::Locked);

                    //The Id-range is only used to lock the query from the Ui
                    rangeId = datasource.addRange(fieldnum(WorkflowWorkItemTable, Id));
                    rangeId.status(RangeStatus::Locked);
                    rangeId.enabled(false);
                    // info(query.dataSourceNo(1).toString());
                    this.query(query);
}
}

Monday, 10 September 2012

EP lookup filterization with two ranges

protected void Item_Lookup(object sender, AxLookupEventArgs e)
    {
        // Boundfield is the sender
        AxBoundField field = (AxBoundField)sender;

        // The underlying control in this case is the lookup control
        AxLookup lookup = e.LookupControl;
        String lookupTable;
        string field_storeAreaId;
        string field_ItemId;
        string field_InventLocationId;
        string field_SiteId;
        string field_ItemName;
        lookupTable = "ItemStoreCombination";
        field_storeAreaId = "storeAreaId";
        field_InventLocationId = "InventLocationId";
        field_ItemId = "ItemId";
        field_SiteId = "SiteId";
        field_ItemName = "ItemName";



        using (Proxy.SysDataSetBuilder sysDataSetBuilder = Proxy.SysDataSetBuilder.constructLookupDataSet(this.AxSession.AxaptaAdapter, TableMetadata.TableNum(this.AxSession, lookupTable)))
        {
            lookup.LookupDataSet = new DataSet(this.AxSession, sysDataSetBuilder.toDataSet());

            // DataSet has to be init'ed before accessing the data sources
            lookup.LookupDataSet.Init();



            // Specify the lookup fields used
            lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.LookupDataSetViewMetadata.ViewFields[field_ItemId]));
            lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.LookupDataSetViewMetadata.ViewFields[field_ItemName]));
            lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.LookupDataSetViewMetadata.ViewFields[field_SiteId]));
            lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.LookupDataSetViewMetadata.ViewFields[field_InventLocationId]));
            DataSetViewRow ItemTableRow = this.AxDataSource2.GetDataSourceView("InventRequestLine").DataSetView.GetCurrent();
            if (ItemTableRow!= null)
            {
                using (IAxaptaRecordAdapter record = ItemTableRow.GetRecord())
                {
                    if (record != null)
EP Lookup Filterization



                    {
                        // Filter the lookup
                        using (Proxy.Query query = lookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
                        {
                            using (Proxy.QueryBuildDataSource dataSource = query.dataSourceNo(1))
                            {
                                using (Proxy.QueryBuildRange range = dataSource.addRange(
                                    TableDataFieldMetadata.FieldNum(AxSession, "ItemStoreCombination", "InventLocationId")))
                                using (Proxy.QueryBuildRange range2 = dataSource.addRange(
                                    TableDataFieldMetadata.FieldNum(AxSession, "ItemStoreCombination", "storeAreaId")))
                                {
                                    range.status = (int)Proxy.RangeStatus.Hidden;
                                    range.value = (string)record.GetField("InventLocationId");
                                    range2.status = (int)Proxy.RangeStatus.Hidden;
                                    range2.value = (string)record.GetField("storeAreaId");
                                }
                            }
                          

                        }
                    }
                }

            }


        }
        // Specify the select field
        lookup.SelectField = field_ItemId;

    }

Tuesday, 28 August 2012

How to add image dynamically from Ax2009 database to SSRS report


i am using following method for employee signature printing in AX2009.

  1. In report design view, create a required table with a data source connection and a dataset with a field that contains binary image data. For more information, see .
  2. Insert a column in your table.
  3. On the Insert menu, click Image, and then click in the data row of the new column.
  4. On the General page of the Image Properties dialog box, type a name in the Name text box or accept the default.
  5. In Select the image source, select Database.
  6. In the Image Properties dialog box, click the expression (fx) button.
    Add following line in expression =System.Text.Encoding.Default.GetBytes(Mid(System.Text.Encoding.Default.GetString(Fields!IMAGE.Value),8))
  7. In Use this MIME type, select the MIME type, or file format, of the image—for example, bmp.
  8. Click OK.


Insert Company logo in SSRS reports (AX)


following useful article for printing companylogo of Ax on SSRS reports of Ax .

http://www.hakasolutions.com/news/51/130/Insert-Company-logo-in-SSRS-reports-AX/