I can do this with a way which I got from a forum forumda . Trick is fetchMode command. Without fetchMode command can't generate a correct select command.
Query query = new Query();
QueryBuildDataSource qbds,qbds1,qbds2;
;
qbds = query.addDataSource(tableNum(SMAServiceOrderTable));
qbds1 = qbds.addDataSource(tableNum(B_RepairJournal));
qbds1.fetchMode(QueryFetchMode::One2One);
qbds1.addLink(fieldNum(B_RepairJournal,ServiceOrderId),fieldNum(SMSServiceOrderTable,ServiceOrderId));
qbds2 = qbds.addDataSource(tableNum(InventTable));
qbds2.fetchMode(QueryFetchMode::One2One);
qbds2.addLink(fieldNum(SMAServiceOrderTable,ItemId),fieldNum(InventTable,ItemId));
info(qbds.toString());
10 Ekim 2013 Perşembe
1 Ekim 2013 Salı
AXAPTA - Web service "CLR object cannot be marshaled to Microsoft Dynamics anytype." error
SenderTel2 = line.get_senderTel2();
If you get "CLR object cannot be marshaled to Microsoft Dynamics anytype." error message when reading value from any services property when value is null and can't hide this error even use try/catch, you have to do:
SenderTel2 = CLRInterop::isNull(line.get_senderTel2()) ? "" : line.get_senderTel2();
If you get "CLR object cannot be marshaled to Microsoft Dynamics anytype." error message when reading value from any services property when value is null and can't hide this error even use try/catch, you have to do:
SenderTel2 = CLRInterop::isNull(line.get_senderTel2()) ? "" : line.get_senderTel2();
23 Temmuz 2013 Salı
AXAPTA - Lookup and sort
When creating lookup you will see lookup won't run with your selected sort field:
public void lookup()
{
SysTableLookUp sysTableLookUp = SysTableLookup::newParameters(tablenum(SMARepairStage),RepairStageId);
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tablenum(SMARepairStage));
qbds.addSortField(fieldnum(SMARepairStage,Name));
qbds.orderMode(OrderMode::OrderBy);
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,RepairStageId));
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,Name));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
If you may do this change, you will see your lookup how do you want to do:
public void lookup()
{
SysTableLookUp sysTableLookUp = SysTableLookup::newParameters(tablenum(SMARepairStage),RepairStageId);
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tablenum(SMARepairStage));
qbds.addSortField(fieldnum(SMARepairStage,Name));
qbds.orderMode(OrderMode::OrderBy);
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,RepairStageId));
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,Name));
sysTableLookup.parmQuery(query);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.performFormLookup();
}
public void lookup()
{
SysTableLookUp sysTableLookUp = SysTableLookup::newParameters(tablenum(SMARepairStage),RepairStageId);
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tablenum(SMARepairStage));
qbds.addSortField(fieldnum(SMARepairStage,Name));
qbds.orderMode(OrderMode::OrderBy);
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,RepairStageId));
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,Name));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
If you may do this change, you will see your lookup how do you want to do:
public void lookup()
{
SysTableLookUp sysTableLookUp = SysTableLookup::newParameters(tablenum(SMARepairStage),RepairStageId);
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(tablenum(SMARepairStage));
qbds.addSortField(fieldnum(SMARepairStage,Name));
qbds.orderMode(OrderMode::OrderBy);
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,RepairStageId));
sysTableLookup.addLookupfield(fieldnum(SMARepairStage,Name));
sysTableLookup.parmQuery(query);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.performFormLookup();
}
22 Temmuz 2013 Pazartesi
AXAPTA - Setfocus to a specified control when opening form
Should write a setfocus for control at form's firstField method:
public void firstField(int _flags=1)
{
super(_flags);
EmplId2.setFocus();
}
public void firstField(int _flags=1)
{
super(_flags);
EmplId2.setFocus();
}
12 Temmuz 2013 Cuma
AXAPTA - Timezone difference when getting server datetime value
DateTimeUtil classes utcNow method gives time as Greenwich time. When getting and setting datetime it needs convert:
CallDateTime.value(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(),DateTimeUtil::getCompanyTimeZone()));
...
...
JournalLines.CallDateTime = DateTimeUtil::removeTimeZoneOffset(CallDateTime.value(),DateTimeUtil::getCompanyTimeZone());
CallDateTime.value(DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(),DateTimeUtil::getCompanyTimeZone()));
...
...
JournalLines.CallDateTime = DateTimeUtil::removeTimeZoneOffset(CallDateTime.value(),DateTimeUtil::getCompanyTimeZone());
11 Temmuz 2013 Perşembe
AXAPTA - Print barcode
Blogs about barcode printing with Axapta usually same each other. There are some problems with Axapta barcode printing and none of them mentioned these problems. I wrote tricks about them at this page:
Code 128:
display BarCodeString ServiceObjectbarCode()
{
Barcode barcode;
;
barcode = BarcodeCode128::construct();
barcode = Barcode::construct(BarcodeType::Code128);
barcode.string(true, ServiceObject.ItemSerialNum);
barcode.encode();
return barcode.barcodeStr();
}
After drag and drop this display method to report section:
Font - BC C128 Narrow
Width - This value shouldn't be auto. Axapta terminate label before needed length. Needed length can find with a few try. I used 10 cm with my sample.
Fontsize - 24 (I couldn't success write readable barcodes below 24. Some bigger font sizes cannot read with barcode reader too, need tries).
Code 39 :
display BarCodeString ServiceOrderbarCode()
{
Barcode barcode;
;
barcode = Barcode::construct(BarcodeType::Code39);
barcode.string(true, ServiceOrder.ServiceOrderId);
barcode.encode();
return barcode.barcodeStr();
}
Font - BC C39 3 to 1 HD Wide
I didn't have trouble when using Code39 about width property when selected Auto. Like Code 128 I had trouble with font sizes below 24 and some sizes upper 24. It may be about my barcode reader.
Code 128:
display BarCodeString ServiceObjectbarCode()
{
Barcode barcode;
;
barcode = BarcodeCode128::construct();
barcode = Barcode::construct(BarcodeType::Code128);
barcode.string(true, ServiceObject.ItemSerialNum);
barcode.encode();
return barcode.barcodeStr();
}
After drag and drop this display method to report section:
Font - BC C128 Narrow
Width - This value shouldn't be auto. Axapta terminate label before needed length. Needed length can find with a few try. I used 10 cm with my sample.
Fontsize - 24 (I couldn't success write readable barcodes below 24. Some bigger font sizes cannot read with barcode reader too, need tries).
Code 39 :
display BarCodeString ServiceOrderbarCode()
{
Barcode barcode;
;
barcode = Barcode::construct(BarcodeType::Code39);
barcode.string(true, ServiceOrder.ServiceOrderId);
barcode.encode();
return barcode.barcodeStr();
}
Font - BC C39 3 to 1 HD Wide
I didn't have trouble when using Code39 about width property when selected Auto. Like Code 128 I had trouble with font sizes below 24 and some sizes upper 24. It may be about my barcode reader.
4 Temmuz 2013 Perşembe
AXAPTA - Set cursor to a record fast with grid
Findrecord and findvalue methods are so slow for set a record for current.
Instead of these filter method can be use but with filter just filtered records can be view. If you want see all records and set cursor to a specific record can use this way which I found at a blog uses from Axapta with also original lookup forms:
element.args().lookupField(fieldnum(SMAServiceOrderTable, ServiceOrderId));
element.args().lookupValue(_order.ServiceOrderId);
SMAServiceOrderTable_ds.executeQuery();
It's so fast but don't forget to use indexed field for search.
element.args().lookupField(fieldnum(SMAServiceOrderTable, ServiceOrderId));
element.args().lookupValue(_order.ServiceOrderId);
SMAServiceOrderTable_ds.executeQuery();
It's so fast but don't forget to use indexed field for search.
Kaydol:
Kayıtlar (Atom)