Data Item Does not Exist When Calling AIF Document Service from C#

By Mark Nelson | May 5, 2016

When calling an AIF document service from a C# you may run into the error “Data item %1 does not exist.”  This error can be particularly frustrating because you can see that you are specifying the value in your application.

You can view the XML received by the service by turning on document logging on the Inbound Port and viewing the AIF History.  This will verify whether the value was actually specified.

To enable document logging:

  1. Click System administration > Setup > Services and Application Integration Framework > Inbound ports
  2. Select your service port.  If it is active, you must deactivate it.
  3. Expand the Troubleshooting Fast Tab.
  4. Change the Logging mode value to Original document.
  5. Activate the port.

To view the XML for a particular service call:

  1. Click System administration > Periodic > Services and Application Integration Framework > History
  2. Select the entry you wish to view.
  3. Click the Document logs button.
  4. Click the View XML button.

The problem is that the value is not transmitted unless the corresponding PropertyNameSpecified property is set to true.  This property indicates that a property value, even if null, should be treated as the actual property value.

The solution is to make sure that you set table.{PropertyName}Specified = true for each value you specify.  If you are calling the service from C# you can create an event handler that makes this task easier.

private static AxdPurchPurchaseOrder getPurchaseOrder()
{
    AxdPurchPurchaseOrder order;
    AxdEntity_PurchTable purchTable;
    AxdEntity_PurchLine purchLine;

    purchTable = new AxdEntity_PurchTable();
    purchTable.PropertyChanged += PurchOrderService.purchTable_PropertyChanged;

    purchTable.AccountingDate = DateTime.Today;
    purchTable.CashDiscPercent = 0.00M;

}

static void purchTable_PropertyChanged(Object sender, System.ComponentModel.PropertyChangedEventArgs args)
{
    Type senderType = sender.GetType();
    string propertyName = String.Format("{0}Specified", args.PropertyName);
    PropertyInfo prop;

    prop = senderType.GetProperty(propertyName);

    if (prop != null)
    {
        prop.SetValue(sender, true);
    }
}

Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!