I'm learning to develop dynamics ax 2012 and I need to find the data in salesTable corresponding to a CustInvoiceJour record.
Does the method CustInvoiceJour.salesTable return the whole table or the associated record?
It returns a sales table buffer that has records associated with customer invoice journal.
The return type of the function is tablebuffer as a tablebuffer type salesTable is return from the function as a foreign key relationship is exist between custinvoicejour and salesTable on salesId field.
SalesTable salesTable = SalesTable::find(this.SalesId, _update);
salestable buffer is find from custinvoicejour current buffer field value this.salesId which is pass into salestable function find which returns salestable buffer contains field values.
SalesTable salesTable(boolean _update = false)
{
SalesTable salesTable = SalesTable::find(this.SalesId, _update);
SalesTableDelete salesTableDelete;
SalesTable_RU salesTableRU;
if (!salesTable && this.SalesId && this.SalesType != SalesType::Journal)
{
salesTableDelete = SalesTableDelete::find(this.SalesId);
if (salesTableDelete.SalesTable)
{
[salesTable] = salesTableDelete.SalesTable;
salesTableRU = SalesTable_RU::findBySalesTable(salesTable.RecId);
salesTable.packSalesTable_RU(salesTableRU);
}
}
return salesTable;
}
Related
I need to add the field of ProductName filterable in the ProductLookup field in retailPeriodicDiscount form. It is strongly connected to EcoResProduct and I can't use any other lookup field or method.
So, I need to add the product name field to productLookup method. Any suggestions how to do it?
For the product name you have to add the field Name of the table EcoResProductTranslation .Add the table as a joined datasource to the query and filter it by the system language.
sysTableLookup.addLookupfield(fieldNum(EcoResProduct, DisplayProductNumber));
sysTableLookup.addLookupfield(fieldNum(EcoResProduct, SearchName));
sysTableLookup.addLookupfield(fieldNum(EcoResProduct, ProductType));
sysTableLookup.addLookupfield(fieldNum(EcoResProductTranslation, Name));
if (_groupMember.Category)
{
query = RetailGroupMemberLineQueryProvider::containedProductsQuery(_groupMember.Category, true /*includesubcategories*/, _dataAreaId);
}
else
{
query = RetailGroupMemberLineQueryProvider::containedProductsQuery(_groupMember.Category, true /*includesubcategories*/, _dataAreaId);
}
// add datasources and join
qbdsProduct = query.dataSourceTable(tableNum(EcoResProduct));
qbdsProductTranslation = qbdsProduct.addDatasource(tableNum(EcoResProductTranslation));
qbdsProduct.relations(true);
// range for system language
qbdsTranslation.addRange(fieldNum(EcoResProductTranslation, LanguageId)).value(SystemParameters::getSystemLanguageId());
sysTableLookup.parmQuery(query);
I want to retrieve the customer name. But in table CustTable there is no field for the customer name. From which table can the customer name be retrieved?
You can retrieve the name using the method name() in table CustTable.
Select the table CustTable and then pass on the result of the method name().
Example:
CustTable custTable;
select custTable where custTable.AccountNum == "YourCustomer";
info(custTable.name());
**I Need to retrive the DeliveryName Field From SalesTable..What is the relationShip Between them ??How Can i retrive the DeliveryName From SalesTable **
for the comments you want get DeliveryName from SalesTable but you need the relation between CustInvoiceJour and SalesTable.
The relation is CustInvoiceJour.SalesId == SalesTable.SalesId
Code:
Select DeliveryName from SalesTable where SalesTable.SalesId == CustInvoiceJour.SalesId;
DeliveryName is field on SalesTable - there is no special relation as this is plain text field.
I'm making a tool in which a user can view data from an entity, where they can choose what data and how they see the records.
I created a form with two date fields (start and end) and a list of fields that correspond to data counts and sums of the entity.
My question is:
How I can create a dynamically QueryBuilder that allows me to add fields based on what the user wants to see?
EDIT for Symfony2 dynamic queryBuilder
public function reportData($fields, $dateStart, $dateFinish)
{
$em = $this->getEntityManager()
->getRepository('AcmeBundle:Entity');
$query = $em->createQueryBuilder('e');
foreach($fields as $field)
{
switch($field)
{
case 'totalResults':
$query->setect('SUM(e.id) AS '.$field);
break;
}
}
$query->addWhere('e.dateStart >= :dateStart');
$query->addWhere('e.dateFinish <= :dateFinish');
...
Something like this ? You store all your select queries in an array, then pass the array to the query builder after testing each of your fields.
public function reportData($fields, $dateStart, $dateFinish)
{
$em = $this->getEntityManager()
->getRepository('AcmeBundle:Entity');
$query = $em->createQueryBuilder('e');
$select_array = array();
foreach($fields as $field)
{
switch($field)
{
case 'totalResults':
$select_array[] = 'SUM(e.id) AS '.$field;
break;
}
}
$query->select($select_array);
$query->addWhere('e.dateStart >= :dateStart');
$query->addWhere('e.dateFinish <= :dateFinish');
....
Basically, you want to keep on adding the
Select Fields
based upon the conditions.
So, the solution is simple.
You can use,
$queryBuilder->addSelect();
See Doctrine Query Builder Documentation
I would do a regular full query then filter it into a not doctrine object (dao/dto) then display it.
This way you can do the complex and optimized query first, then filter the result on whatever you want, even if it's not related to the query itself
A Symfony2 Query is returning all values in an array except one value which is a primary key of an another table. Both in CreateQueryBuilder and FindOneBy I'm not able to get the value but I can get all other values from the table. Why?
$repository123 = $em->getRepository('LoginLoginBundle:Clientuserdetails');
$client_userdetail = $repository123->createQueryBuilder('cud')
->where('cud.userid = ' . $userid)
->getQuery();
$clientuserdet = $client_userdetail->getResult();
Here userid is an entity in Clientuserdetails(). It refers to another table userdetails. Even I passed the userid in the query, I can get all the field values except userid.