11/06/2016

Axapta : Axapta Create Forms And Query Filter Data Some Rows Show In Forms.

Axapta : Axapta Create Forms And Query Filter Data Some Rows Show In Forms.

Example :
We mush select filter some data on table InvenSum. Where AvailPhysical != 0


Step 1: Declare a class variable
In the ClassDeclaration method of the form, define a range.
  1. QueryBuildRange  AvailPhysicalQBR;


Step 2: Instantiate the new range.
In the init method on the datasource of the form, you assign the range to a specific field (after the super call).
  1. public void executeQuery()
  2. {
  3. ;
  4.     AvailPhysicalQBR.value(queryvalue('!0'));
  5.  
  6. super();
  7. }


Step 3: In the last step, you assign a value to the range.
This is done in the executeQuery method on the same datasource of the form. Before the super call. Like this:
  1. public void init()
  2. {
  3. super();
  4.  
  5.     AvailPhysicalQBR = this.query().dataSourceName('InventSum').addRange(fieldnum(InventSum,AvailPhysical));
  6. }


You're done! When you open the form, your item Onhand records are filtered, you only get the AvailPhysical != 0.

http://dynamics-ax-live.blogspot.com/2010/03/how-to-filter-records-in-form-by-code.html


หรือต้องการใช้ Like ค้นหาโดยใช้ * เช่นค้นหาเฉพาะ Name ที่เป็น V* ใช้ .value ได้เลย เช่น
  1.    ValveQBR = this.query().dataSourceName('ProdTable').addRange(fieldnum(ProdTable, Name));
  2.     ValveQBR.value('V*');

ตัวอย่าง ProdTableAssemblyTest

No comments:

Post a Comment