Friday 9 November 2012

Get customer or prospects in Dynamics AX 2012

If you go to the source of isCustomerOrRelation (and isCustomer and isRelation) you see, that the method returns true if a customer or prospect exists in the current company.

Your while select, while correct, is inefficient, because it may have to scan a million parties to select on thousand customers or prospects present in you current company.

A more efficient, but syntactical illegal, while select would be:

while select * from dirPartyTable
   exists join custTable
   where custTable.Party == dirPartyTable.RecId
   union 
   select * from dirPartyTable
   exists join smmBusRelTable
   where smmBusRelTable.Party == dirPartyTable.RecId;
{
     info(dirPartyTable.Name);
}

No comments:

Post a Comment