Thursday, November 02, 2006

Custom Validation Modifications to AIF

Yesterday I was able to fully setup a custom validation within AIF. The validation was regarding ItemIds (Part Numbers) in AX. Out of the box, when the 'createListSalesOrder' action is executed on an inbound XML Sales Order, the entire process halts upon validation of an invalid ItemId (one that is not in the Item List (InventTable). I developed a workaround to check for the current ItemId's existence in the InventTable and if it's not present, replace the invalid ItemId with a valid catch-all ItemId, which will allow AIF to continue processing the Sales Order. So far this modification has been successful.

In general terms, you can make customizations to any of AIF's transactions simply by modifying the appropriate parm[field_name] method within the appropriate Ax[Table] class for the field that you want to add addition customizations on. In my example, I modified the parmItemId method within the AxSalesLine class. Here is the new parmItemId() method with my modification:

public str parmItemId(str _itemId = '')
{
DictField dictField;
ItemId tempItemId;
InventTable tempInventTable;
;

//My custom code to validate ItemId's existence in the Item Master and replace w/ 'InvalidItem' if not
tempItemId = _itemId;
SELECT FIRSTONLY ItemId FROM tempInventTable WHERE tempInventTable.ItemId == tempItemId;
if (tempInventTable.ItemId != _itemId)
{
_itemId = "**INVALIDITEM**";
salesLine.ItemId = _itemId;
salesLine.Name = tempItemId;
}

if (!prmisdefault(_itemId))
{
dictField = new DictField(tablenum(SalesLine),fieldnum(SalesLine,ItemId));
this.validateInboundItemIdString(_itemId,dictField);
if (this.valueMappingInbound())
{
item = _itemId;
}

this.setField(fieldnum(SalesLine, ItemId), _itemId);
}

if (this.valueMappingOutbound())
{
return conpeek(this.axSalesItemId(salesLine.CustAccount,salesLine.ItemId,salesLine.inventDim()),1);
}
else
{
return salesLine.ItemId;
}
}


Although this is my first shot at AIF modification, I would recommend placing your modification above the existing code. The out of the box code does other validations and checks like seeing whether or not AIF should place default data into a field.

Hope this helps!

6 comments:

Anonymous said...

For Sale By Owner makes selling a home on your own easy. We sell the most houses for sale by owner, proving our house selling strategies sell more homes than any site in home selling.

Real Estate

Luxury Homes and luxury real estate for sale in California, Florida, Arizona, Nevada, New York, Texas, France, Beverly Hills, Hollywood, Hollywood Hills, Malibu.

Real Estate
Real Estate

Anonymous said...

Hello David, did you ever try using the freeTextInvoice inbound? I seem to be getting an XML schema error whenever i try, where my createSalesOrder is working like a charm.

vmichnik@yahoo.com

Anonymous said...

Dave did you try using the createFreeTextInvoice inbound? I cant get it to work, keep on getting the schema validation errors while createSalesOrder works like a charm

Anonymous said...

Hi Dave,

I have come across your note regarding ReadList action type here:

http://www.microsoft.com/Businesssolutions/Community/Newsgroups/dgbrowser/en-us/default.mspx?query=pack+map&dg=microsoft.public.axapta&cat=&lang=en&cr=US&pt=&catlist=8d3f188d-a0E9-40e4-86e2-46508a35c759&dglist=&ptlist=&exp=&sloc=en-us


Your blog has no reference to this particular action. Would you mind sharing the steps/code that are needed to create such action type?

Thank you in advance!

Eli. egoby@yahoo.com

Anonymous said...

Post, thanks were a beverly hills real estate blog that caters to blog readers in cheviot hills and beverly hills. So thanks and well pass on out our senior club too, to read your blog
Beverly Hills Real Estate Agents

Unknown said...

I like your blog. It was incredible and well written. I was impressed with your thoughts. Big thanks and keep sharing.



philippine homes