Wednesday, October 30, 2013

DropDown

1. The approach used most in the application is the implicit lookup based on table fields. As you can see from the control properties, DataSource and DataField specify which table field the control is based on. In my example, it is based on SalesTable.CustAccount, which uses the ExtendedDataType CustAccount, which has a relation to CustTable.AccountNum. Therefore, any time you add this field to a form, it will automatically provide a lookup button to select one of the customers.
Relations being specified on EDTs is at times confusing to people, who are used to seeing the relations between tables on the tables themselves. Technically speaking, such definitions on EDTs are incorrect. But no worries, AX supports the “correct” scenario out of the box as well. The relation to CustTable could have been specified on the table just as well.

2. 2nd most used approach is to specify the ExtendedDataType on the control directly. This is used to allow the user to specify a value to filter the records on directly from the form, for example (without the need to go to Extended Query form). It is also indirectly used on all RunBase dialogs in the system (when creating a DialogField, we specify the EDT to be used, which is transfered to the ExtendedDataType property on the corresponding control). In the tutorial, it is again the CustAccount EDT that is specified in the properties.

3. The 2 above examples both used metadata to define what lookup is to be displayed. The 3rd most used approach is relying on SysTableLookup class and builds the lookup at runtime. The code is relatively straightforward, and is described in more detail on MSDN. Using this approach, the developer can specify the query to filter the data being displayed in the lookup form. Note, that SysTableLookup only allows to have data from one table in the lookup form (+ display methods on this table). SysMultiTableLookup is an extension I have created a while ago, that adds this and other useful functionality to SysTableLookup class.

4. The remaining 2 standard approaches are rarely used in the application. Lookup based on ExtendedDataType is very similar to approach described under #2, but is executed from code at runtime. This way, you can change the lookup data displayed dynamically, based on some conditions (For example, on Ledger Journal lines, the offset account lookup shows vendors, customers, banks, etc. based on the offset account type specified on the line).

5. BaseEnum values are usually represented as a ComboBox (and, in special cases, CheckBox or RadioButton) control on forms in Dynamics AX. The lookup is provided by the kernel automatically for this type of control. But, sometimes, it is required to show the values of an enumeration in a string control – most common scenario is providing filter capabilities based on enums, where multiple values can be specified at once, similar to extended query form filters. In fact, this approach is actually used on SysQueryForm for enum fields. As you can see from the code, the lookup call is also very simple in this case.

http://kashperuk.blogspot.com/2009/04/lookup-methods-tutorial-custom-list.html

Thursday, October 24, 2013

ExistsJoin

List all the customers that has entries in the Sales table.

    Query                   query;
    QueryBuildDatasource    datasource,SalesDataSource,CustomerDataSource;
    QueryRun   queryrun;
    CustTable custtable;
    SalesTable salesTable;
    query = new Query();
    CustomerDataSource  = query.addDataSource(tableNum(CustTable ));
    SalesDataSource  = CustomerDataSource.addDataSource(tableNum(SalesTable ));
 
    SalesDataSource.joinMode(JoinMode::ExistsJoin   );
 
    SalesDataSource.relations(false);

    SalesDataSource.addLink(fieldNum(CustTable, AccountNum),
    fieldNum(SalesTable  , CustAccount ));
    queryrun = new QueryRun(query);
    while(queryRun.next())
    {
        custtable = queryRun.get(tablenum(CustTable ));
        Info(custtable.AccountNum);
    }

List customers who has entries in the project table
    Query q;
    QueryBuildDataSource        vrfQBDSCustTable;
     QueryBuildDataSource        qbr1;
   
    q = new Query();
    vrfQBDSCustTable = q.addDataSource(tableNum(CustTable));
    qbr1 = vrfQBDSCustTable.addDataSource(tableNum(ProjTable));
    qbr1.joinMode(JoinMode::ExistsJoin);
    qbr1.relations(true);
   
    info(q.xml());

Timesheet Process

Create a new timesheet,
Submit for approval, after it is approved
The timesheet is in “Unposted timesheets”, then posted it.
After it is posted, it can be found in “Posted project transactions”.
From all project, find the project which timesheet was created based on. Create an invoice proposal.
The invoice proposal can be found in PMA/common/project invoices/invoice proposals, post the invoice proposal,
After invoice proposal has been posted, the status updated to “Invoiced”

To find the posted data, go to General Ledger\Voucher Transactions

Tuesday, October 22, 2013

tmpdata

PSATmpSchedEmplResource             tEmplResource;
tEmplResource.setTmpData(tmpSchedEmplResource);

update data in tEmplResource
once tEmplResource is out of the scope, it is deleted. 
Updated data is still at tmpSchedEmplResource

tmpSchedEmplResource contains the data, after setTmpData is called, tEmpResource will contains the data. Edit/Update data in tEmplResource will update data in tmpScheEmplResource. 


1. Create temporary table as TmpTestTable with 3 fields(ItemId,Itemname,ItemGroup).
2. Create a form as TempTestTable and attach the table as datasource
3. Create a new method on the form and copy the following code

TmpTestTable populateRecords(ItemGroupId _itemGroupId)
{
 
TmpTestTable tmpTable;
InventTable inventTable;
;

while select inventTable
where inventTable.ItemGroupId == _itemGroupId
{
tmpTable.Itemid = inventTable.ItemId;
tmpTable.ItemName = inventTable.ItemName;
tmpTable.Itemgroup = inventTable.ItemGroupId;
tmpTable.insert();
}

return tmpTable;


4. Call the above method in init() after super as below
public void init()
{
 
super();

// Call the setTmpData method to attach records to datasource
TmpTestTable.setTmpData(element.populateRecords("Parts"));
}

Sunday, October 20, 2013

Create a reference dropdown

  1. 1.       PSAActivitySetup VRFSPPRequestor create EDT, EDT’s table reference points to the hcmWorker.
  2. 2.       On PSAActivitySetup create a new field, the new field’s EDT is the newly created EDT.
  3. 3.       Create new relation on the PSAActivitySetup table. The relation needs to be used the new field pointing to the hcmWork recid
  4. 4.       On hcmWorker field, whatever needs to be displayed from the dropdown needs to be drag and dropped into the autoidentification group.
  5. 5.       On the ProjTable form, to either drag and drop from datasource or right click to create a new reference group.