How to get detailed error log when integrating with AIF framework.

Me and my team works on complex projects which involves integration with AX / Oracle. While working on one of the project which involved AX integration where we had to develop a middle-ware piece to communicate between a custom eCommerce solution and AX. The medium we chose to integrate with AX was AIF.

We hosted inbound port in AX with http binding and configured the Sales Order & Customer Service classes to perform operations such as

  • Creating Sales Order in AX
  • Update sales order information in AX.
  • Create & update customer information in AX.
  • Create payment journals in AX.

It is critical to handle exception in integration, since you require a detailed report of what failed. Here we faced issues since AIF only provides the last level of exception, for e.g. in case if a sales order failed to be created in AX, it sends only the last error which is “Creation has been canceled”, however from the exception manager in AX you can get the complete details about the failure , but you will have to do guess work as well as, you will have to get throguh the document logs and history section to get the exact error message for your request.

While doing further analysis we found that AX provides a fault class “AifFault”. Whenever any aif operations fails AX sends a fault exception back to user, in the message section it gives the final error but further analyzing the same we found out that internally it also has one section “InfoLogMessageList”. Whoever has worked in AX knows about what is info-log so , i won’t go further with what is info log, but just to give a brief info-log stores all the events and warning when a certain activity is performed.

That’s it we got our solution to have a detailed error message. below is the example of how to get the detailed errors and warnings when performing any operations with AIF.

        errorfault

That’s about it :). Let me know if you found this article helpful into your coding.

“Happy Coding”

Creating Customer in AX 2012 through AIF [MSMQ Message Exchange].

Here i will share a simple example about how to create a customer in AX through AIF.
Below is a Sample Customer create request.

<Envelope xmlns:InternalCO="http://InternalCustomer" xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
  <Header>
    <MessageId>{8A014186-840C-4380-8F46-88C56E8813BD}</MessageId>
    <Action>http://schemas.microsoft.com/dynamics/2008/01/services/CustomerService/create</Action>
  </Header>
  <Body>
    <MessageParts>
      <Customer xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Customer">
        <CustTable class="entity">
          <CustGroup>##</CustGroup>
          <DirParty class="entity" xsi:type="AxdEntity_DirParty_DirPerson" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <LanguageId>##</LanguageId>
            <Name>##</Name>
            <NameAlias>##</NameAlias>
            <DirPartyPostalAddressView class="entity">
              <Address>##</Address>
              <City>##</City>
              <CountryRegionId>as per ax</CountryRegionId>
              <IsPrimary>wh</IsPrimary>
              <LocationName>##</LocationName>
              <Roles>##</Roles>
            </DirPartyPostalAddressView>
            <DirPartyContactInfoView class="entity">
              <IsPrimary>##</IsPrimary>
              <LocationName>##</LocationName>
              <Locator>##</Locator>
              <Roles>##</Roles>
              <Type>##</Type>
            </DirPartyContactInfoView>
            <PersonName class="entity">
              <FirstName>##</FirstName>
              <LastName>##</LastName>
              <MiddleName>##</MiddleName>
            </PersonName>
          </DirParty>
        </CustTable>
      </Customer>
    </MessageParts>
  </Body>
</Envelope>

Few things to note here.
If you are creating a party of type Person you need to mention below lines in your code.

  <DirParty class="entity" xsi:type="AxdEntity_DirParty_DirPerson" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

also

            <PersonName class="entity">
              <FirstName>##</FirstName>
              <LastName>##</LastName>
              <MiddleName>##</MiddleName>
            </PersonName>

If you are creating a party of type Organization you need to mention below lines in your code.

  <DirParty class="entity" xsi:type="AxdEntity_DirParty_DirOrganization" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

also you need to remove the personname section.

You need to place this message in the MSMQ request queue created for exchanging of messages.
If the message is successfully processed in AX you will get the below response.

<Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
	<Header>
		<MessageId>{E7039032-798A-43E1-8F83-45BE81CBC542}</MessageId>
		<Action>http://schemas.microsoft.com/dynamics/2008/01/services/CustCustomerService/create</Action>
		<RequestMessageId>{8A014186-840C-4380-8F46-88C56E8813BD}</RequestMessageId>
	</Header>
	<Body>
		<MessageParts xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
			<EntityKeyList xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKeyList">
				<EntityKey xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
					<KeyData>
						<KeyField>
							<Field>AccountNum</Field>
							<Value>##########</Value>
						</KeyField>
					</KeyData>
				</EntityKey>
			</EntityKeyList>
		</MessageParts>
	</Body>
</Envelope>

Unfinished……….

one of my unfinished poem.

Ae zindagi badi ajeeb hai tu
suljhi si lagti par bahot uljhi hai tu
kabhi chav to kabhi kadi dhoop hai tu
aise hote hua bhi sabko aziz hai tu
ae zindagi badi ajeeb hai tu..

kuch logo ko suna hai kehte
ke zindagi se hum ne sab pa liya..
pata hai bas tu janati hai..
wo paane ke liye usane kya kya khoya..

budhape ki jhuriyon mein
to kabhi khamosh aankhon mein sehemati hai tu
jawani ke josh mein
to kabhi bacche ke muskaan mein chehekati tu

ae zindagi badi ajeeb hai tu
suljhi si lagti par bahot uljhi hai tu

Zindagii…..

when we started thinking of forming a band we decided to compose something of our own rather than doing the covers and this is the second poem i wrote for the band……..

Zindagi……

Zindagi… Zindagi..
Kuch Pal De De Udhaar
Kuch Lamhe Zindagi ke Mujhe Jeene hai Ek Baar Phir Se
Zindagi… Zindagi..

Kuch Khwaishe hai baaki
Kuch Khwab hai adhure se
Kuch Panne zindagi ke
Jo reh gaye anchuye se

De waqt sa.. hai hausla poora
Kuch Kar guzarne ki… ummid se bhara hua hai dil..
Yeh Dil…

Zindagi… Zindagi..
Kuch Pal De De Udhaar
Kuch Lamhe Zindagi ke Mujhe Jeene hai Ek Baar Phir Se
Zindagi… Zindagi..

Ek rishta dil se dil ka
Peeche chuta hai kahi par
Ek dil jo khoobsoorat tha
Mujhase toota hai kahi par

De sabra thoda usse
Bhar du usse pyaar se.  Na rahe koi shikwa na gham
rahe pyaar hi bas darmiyan  kuch aisa kar de karam..

Zindagi… Zindagi..
Kuch Pal De De Udhaar
Kuch Lamhe Zindagi ke Mujhe Jeene hai Ek Baar Phir Se
Zindagi… Zindagi..

we had worked on the tune for the song but yet to finalize…………..

SharePoint Form Customizations – Customizing CreatedModifiedInfo

Recently…while working on one of the project in SharePoint. We had an requirement where we wanted to customize the default SharePoint list display form to show some extra fields like Created , Modified, Created By, Modified By. By default in the display form SharePoint doesn’t provide these fields since these are system field. but the requirement was such that these fields need to be shown on the display form in the same format as the other fields.  the page used to look like this.

The requirement was such that like the fields class,division and student name the created and modified details also should be displayed as a form field on the form. We did following steps to customize the form.

  1. Open the site in SharePoint designer.
  2. Navigate through site objects  List and Libraries >[List Name] and click on the list name.
  3. Once you do that it will take you to the manage page where you can see many web-parts which help us to change a particular property of the list.
  4. Now in the forms section right click on the DispForm.aspx and select “Edit File in Advanced Mode” from the context menu.
  5. This will open the display form for editing. By default SharePoint uses list form web part to show data on to the form. But we can do modification to this web part. so we need to create a new web-part.
  6. For adding a new web-part to the form simple click below the current web-part in any empty div and from the Insert menu under the Data Views and Forms menu click on the Display Item Form choice button. it will connect to the site and will bring you all the list names from the site. Don’t select the list name that you are working on instead select the custom list form option.
  7. It will open a dialog box where in first dropdown box you select the list you are working on. From the radio options slecte the display form and un check the show standard toolbar button.
  8. Once you click on OK a more user friendly form will be created on the form that you are customizing.
  9. For Showing the audit details i.e.Created, Modified, Created By and Modified By values SharePoint uses a user control that is “<SharePoint:CreatedModifiedInfo ControlMode=”Display” runat=”server”/>” and this has a basic template assigned which shows the data in a particular format.
  10. Now to customize this control and to show the data as per our need we need to assign a custom template for this user control this can be done by following way.
  11. <SharePoint:CreatedModifiedInfo ControlMode=”Display” runat=”server”>
    <CustomTemplate>
    ————————<SharePoint:FormField ControlMode=”Display” FieldName=”Author” DisableInputFieldLabel=”true” runat=”server”/>
    ——————————
    <SharePoint:FormField ControlMode=”Display” FieldName=”Created” DisableInputFieldLabel=”true” runat=”server”/>
    ———————————
    <SharePoint:FormField ControlMode=”Display” FieldName=”Editor” DisableInputFieldLabel=”true” runat=”server”  />
    —————————————-
    <SharePoint:FormField ControlMode=”Display” FieldName=”Modified” DisableInputFieldLabel=”true” runat=”server”/>
    ————————————–
    </CustomTemplate>
    </SharePoint:CreatedModifiedInfo>
  12. For our need we just added a tabular structure so the code looks like this.
  13. <SharePoint:CreatedModifiedInfo ControlMode=”Display” runat=”server”>
    <CustomTemplate>
    <table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”0″>
    <tr>
    <td width=”190px” valign=”top” >
    <H3>
    <nobr>Created By</nobr>
    </H3>
    </td><td width=”400px” valign=”top”><SharePoint:FormField ControlMode=”Display” FieldName=”Author” DisableInputFieldLabel=”true” runat=”server”/>
    </td>
    </tr>
    <tr>
    <td width=”190px” valign=”top” >
    <H3>
    <nobr>Created On</nobr>
    </H3>
    </td><td width=”400px” valign=”top”>
    <SharePoint:FormField ControlMode=”Display” FieldName=”Created” DisableInputFieldLabel=”true” runat=”server”/>
    </td>
    </tr>
    <tr>
    <td width=”190px” valign=”top” >
    <H3>
    <nobr>Modified By</nobr>
    </H3>
    </td><td width=”400px” valign=”top”>
    <SharePoint:FormField ControlMode=”Display” FieldName=”Editor” DisableInputFieldLabel=”true” runat=”server”  />
    </td>
    </tr>
    <tr>
    <td width=”190px” valign=”top” >
    <H3>
    <nobr>Modified On</nobr>
    </H3>
    </td><td width=”400px” valign=”top”>
    <SharePoint:FormField ControlMode=”Display” FieldName=”Modified” DisableInputFieldLabel=”true” runat=”server”/>
    </td>
    </tr>
    </table>
    </CustomTemplate>
    </SharePoint:CreatedModifiedInfo>
  14. The last thing that needs to be done here is to hide the default web-part on the page. this can be done through accessing the page via the in build page editor in SharePoint or from web-part properties in SharePoint designer itself by selecting the hidden property.
  15. The out put looks like this.
  16. Thats it your newly customized display form with all the additional fields.