Demand:
The counting journal lines are queried based on the user input time period (posting date). Ask for a field to appear:
Journal (journalid), date, item number, size, color, site, warehouse, location, hand, count quantity, actual cost amount.
Design:
Create form: inventcountedtable
To add a data source (Sources):
InventJournalTrans (Main table), Inventtransorigin, InventTrans, InventDim, inventjournaltable
Set the Allow property of all tables to no to prevent users from editing records.
InventTransOrigin:JoinSource:InventJournalTrans; Linktype:innerjoin (link to Main table)
InventTrans:JoinSource:InventTransOrigin; Linktype:innverjoin (associated to Inventtransorigin, these two tables are a one-to-many relationship through recid associations, and the Inventtransorigin table holds the public fields of InventTrans).
InventDim:JoinSource:InventJournalTrans:LinkType:InnerJoin (link to Main table)
InventJournalTable:JoinSource:InventJournalTrans; Linktype:innerjoin (link to Main table)
Add Control (Design)
Set up a data source for design datasource:inventjournaltrans,caption= counting journal details
Add two group controls, set the control Width&height=column width&column Height.
The first group control adds a query condition and a query button.
Fromdatetime:utcdatetimeedit, Label=from:, Autodeclaration=yes
Todatetime:utcdatetimeedit, Label=to:, Autodeclaration=yes
Btnquery:button, label= Query
Sets the second group control's data source Datasource:inventjournaltrans, which adds a grid to save the results of a query.
Drag the fields that the user needs to display to the grid, set the grid data source InventJournalTrans, Width&height=column width&column Height.
Coding:
Declare the variable in the form declaration method:
Public class FormRun extends objectrun{ //Firstopen form no data shows flag boolean Firstflag; // The range of journal name querybuildrange qbrjournalname; // The range of posted date querybuildrange Qbrdt; // The range of posted or not querybuildrange qbrposted;}
Query button override method Click ()
void clicked () {super ();
Perform a query operation on the data source Inventjournaltrans_ds.executequery ();}
ExecuteQuery method of data source InventJournalTrans overlay method
Public voidExecuteQuery () {//Make sure, correct records showsQbrjournalname =Sysquery::findorcreaterange (inventjournaltrans_q.datasourcetable (Tablenum (inventjournaltable)), FieldNum ( InventJournalTable, Journalnameid)); if(!Firstflag) {Qbrjournalname.value ("Null"); Firstflag=true; } Else{Qbrjournalname.value ("Imov"); } qbrjournalname.status (rangestatus::locked); //ADD range of posted recordsqbrposted =Sysquery::findorcreaterange (inventjournaltrans_q.datasourcetable (Tablenum (inventjournaltable)), FieldNum ( inventjournaltable,posted)); //Qbrposted.value (Enum2str (Noyes::yes));Qbrposted.status (rangestatus::locked); //ADD range of posted date timeQbrdt =Sysquery::findorcreaterange (inventjournaltrans_q.datasourcetable (Tablenum (inventjournaltable)), FieldNum ( Inventjournaltable,posteddatetime)); Qbrdt.value (Fromdatetime.valuestr ()+".."+todatetime.valuestr ()); Qbrdt.status (rangestatus::locked); Super ();}
Current:
Verify that the Fromdatetime and ToDateTime two controls are not empty at the beginning of the query, and that the time does not cross (verified in the button's click Time):
void clicked () {super (); if (Fromdatetime.valuestr ()) { Span style= "color: #0000ff;" >if (Fromdatetime.valuestr () > Todatetime.valuestr ()) {error ( " " ); else {Inventjournalt Rans_ds.executequery (); }} else {error ( ' Start date cannot be empty! " ); }}
Pending improvement:
1. Set the initial value for the UtcDateTime control ToDateTime to the current time (processed in the form method init)
Dynamics AX counting journal lines